Perl bindings fix: Not enough memory was allocated for array params.
authorRichard Jones <rjones@redhat.com>
Mon, 11 May 2009 09:51:21 +0000 (10:51 +0100)
committerRichard Jones <rjones@redhat.com>
Mon, 11 May 2009 09:52:34 +0000 (10:52 +0100)
BUGS
perl/Guestfs.xs
src/generator.ml

diff --git a/BUGS b/BUGS
index 2715ba7..2732f52 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -54,3 +54,4 @@ quite hard to fix cleanly.
 
 [perl] Perl bindings cause a segfault when you call any command which
 takes a StringList (eg. $g->command).
 
 [perl] Perl bindings cause a segfault when you call any command which
 takes a StringList (eg. $g->command).
+[should be fixed now]
index 27e03d0..5ce5def 100644 (file)
@@ -68,7 +68,7 @@ XS_unpack_charPtrPtr (SV *arg) {
     croak ("array reference expected");
 
   av = (AV *)SvRV (arg);
     croak ("array reference expected");
 
   av = (AV *)SvRV (arg);
-  ret = malloc (av_len (av) + 1 + 1);
+  ret = malloc ((av_len (av) + 1 + 1) * sizeof (char *));
   if (!ret)
     croak ("malloc failed");
 
   if (!ret)
     croak ("malloc failed");
 
index f7057d0..7f24802 100755 (executable)
@@ -4862,7 +4862,7 @@ XS_unpack_charPtrPtr (SV *arg) {
     croak (\"array reference expected\");
 
   av = (AV *)SvRV (arg);
     croak (\"array reference expected\");
 
   av = (AV *)SvRV (arg);
-  ret = malloc (av_len (av) + 1 + 1);
+  ret = malloc ((av_len (av) + 1 + 1) * sizeof (char *));
   if (!ret)
     croak (\"malloc failed\");
 
   if (!ret)
     croak (\"malloc failed\");