* qemud/driver.c: apply patch from Jim Meyering to handle realloc

failure without leaking.
Daniel
This commit is contained in:
Daniel Veillard 2007-06-22 10:14:48 +00:00
parent e8b0f8a251
commit 65d0b1910b
2 changed files with 10 additions and 1 deletions

View File

@ -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> 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. * docs/virsh.pod: Fixed a few typos and POD directives.

View File

@ -75,6 +75,7 @@ int qemudMonitorCommand(struct qemud_server *server ATTRIBUTE_UNUSED,
for (;;) { for (;;) {
char data[1024]; char data[1024];
int got = read(vm->monitor, data, sizeof(data)); int got = read(vm->monitor, data, sizeof(data));
char *b;
if (got == 0) { if (got == 0) {
if (buf) if (buf)
@ -91,8 +92,11 @@ int qemudMonitorCommand(struct qemud_server *server ATTRIBUTE_UNUSED,
free(buf); free(buf);
return -1; return -1;
} }
if (!(buf = realloc(buf, size+got+1))) if (!(b = realloc(buf, size+got+1))) {
free(buf);
return -1; return -1;
}
buf = b;
memmove(buf+size, data, got); memmove(buf+size, data, got);
buf[size+got] = '\0'; buf[size+got] = '\0';
size += got; size += got;