diff options
author | Richard Jones <rjones@redhat.com> | 2009-04-30 14:01:53 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-04-30 14:01:53 +0100 |
commit | ab0397017cc26833c09946cca19d86b907822a94 (patch) | |
tree | 6bed84d3921570c84e7e6d9d9fc7b16889aa7c92 /perl | |
parent | 6f5c3984a7ddfc111287e2ec214ba823db737db4 (diff) | |
download | libguestfs-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.xs | 7 |
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); |