]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
* qemud/driver.c: apply patch from Jim Meyering to handle realloc
authorDaniel Veillard <veillard@redhat.com>
Fri, 22 Jun 2007 10:14:48 +0000 (10:14 +0000)
committerDaniel Veillard <veillard@redhat.com>
Fri, 22 Jun 2007 10:14:48 +0000 (10:14 +0000)
  failure without leaking.
Daniel

ChangeLog
qemud/driver.c

index 398ef9b5a642d3e7f65b0bb06229178d100311cb..30311f2890db1850919cbf7bbab19a97bd453ee2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Jun 22 12:14:40 CEST 2007 Daniel Veillard <veillard@redhat.com>
+
+       * qemud/driver.c: apply patch from Jim Meyering to handle realloc
+         failure without leaking.
+
 Thu Jun 21 16:56:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
 
        * docs/virsh.pod: Fixed a few typos and POD directives.
index 1bcb66f5163f1489213b50ae58c08fa4cc595510..6ef3aa47419a14f303fdd8816d1bd439e9451446 100644 (file)
@@ -75,6 +75,7 @@ int qemudMonitorCommand(struct qemud_server *server ATTRIBUTE_UNUSED,
         for (;;) {
             char data[1024];
             int got = read(vm->monitor, data, sizeof(data));
+            char *b;
 
             if (got == 0) {
                 if (buf)
@@ -91,8 +92,11 @@ int qemudMonitorCommand(struct qemud_server *server ATTRIBUTE_UNUSED,
                     free(buf);
                 return -1;
             }
-            if (!(buf = realloc(buf, size+got+1)))
+            if (!(b = realloc(buf, size+got+1))) {
+                free(buf);
                 return -1;
+            }
+            buf = b;
             memmove(buf+size, data, got);
             buf[size+got] = '\0';
             size += got;