summaryrefslogtreecommitdiffstats
path: root/perl
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-04-30 14:01:53 +0100
committerRichard Jones <rjones@redhat.com>2009-04-30 14:01:53 +0100
commitab0397017cc26833c09946cca19d86b907822a94 (patch)
tree6bed84d3921570c84e7e6d9d9fc7b16889aa7c92 /perl
parent6f5c3984a7ddfc111287e2ec214ba823db737db4 (diff)
downloadlibguestfs-ab0397017cc26833c09946cca19d86b907822a94.tar.gz
libguestfs-ab0397017cc26833c09946cca19d86b907822a94.tar.xz
libguestfs-ab0397017cc26833c09946cca19d86b907822a94.zip
Use safe_malloc and/or check returns from malloc (Jim Meyering).
Diffstat (limited to 'perl')
-rw-r--r--perl/Guestfs.xs7
1 files changed, 4 insertions, 3 deletions
diff --git a/perl/Guestfs.xs b/perl/Guestfs.xs
index 12c6cbbc..9d8a49cf 100644
--- a/perl/Guestfs.xs
+++ b/perl/Guestfs.xs
@@ -64,12 +64,13 @@ XS_unpack_charPtrPtr (SV *arg) {
AV *av;
I32 i;
- if (!arg || !SvOK (arg) || !SvROK (arg) || SvTYPE (SvRV (arg)) != SVt_PVAV) {
+ if (!arg || !SvOK (arg) || !SvROK (arg) || SvTYPE (SvRV (arg)) != SVt_PVAV)
croak ("array reference expected");
- }
av = (AV *)SvRV (arg);
- ret = (char **)malloc (av_len (av) + 1 + 1);
+ ret = malloc (av_len (av) + 1 + 1);
+ if (!ret)
+ croak ("malloc failed");
for (i = 0; i <= av_len (av); i++) {
SV **elem = av_fetch (av, i, 0);