render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Daniel P. Berrange 511f6c
Index: src/xend_internal.c
Daniel P. Berrange 511f6c
===================================================================
Daniel P. Berrange 511f6c
RCS file: /data/cvs/libxen/src/xend_internal.c,v
Daniel P. Berrange 511f6c
retrieving revision 1.251
Daniel P. Berrange 511f6c
diff -u -r1.251 xend_internal.c
Daniel P. Berrange 511f6c
--- src/xend_internal.c	13 Feb 2009 18:23:23 -0000	1.251
Daniel P. Berrange 511f6c
+++ src/xend_internal.c	10 Mar 2009 10:00:28 -0000
Daniel P. Berrange 511f6c
@@ -904,7 +904,15 @@
Daniel P. Berrange 511f6c
         count++;
Daniel P. Berrange 511f6c
     }
Daniel P. Berrange 511f6c
 
Daniel P. Berrange 511f6c
-    if (VIR_ALLOC_N(ptr, count + 1 + extra) < 0)
Daniel P. Berrange 511f6c
+    /*
Daniel P. Berrange 511f6c
+     * We can'tuse the normal allocation routines as we are mixing
Daniel P. Berrange 511f6c
+     * an array of char * at the beginning followed by an array of char
Daniel P. Berrange 511f6c
+     * ret points to the NULL terminated array of char *
Daniel P. Berrange 511f6c
+     * ptr points to the current string after that array but in the same
Daniel P. Berrange 511f6c
+     * allocated block
Daniel P. Berrange 511f6c
+     */
Daniel P. Berrange 511f6c
+    if (virAlloc((void *)&ptr,
Daniel P. Berrange 511f6c
+                 (count + 1) * sizeof(char *) + extra * sizeof(char)) < 0)
Daniel P. Berrange 511f6c
         goto error;
Daniel P. Berrange 511f6c
 
Daniel P. Berrange 511f6c
     ret = (char **) ptr;