summaryrefslogtreecommitdiffstats
path: root/daemon/guestfsd.c
diff options
context:
space:
mode:
authorRichard Jones <rjones@centos5x32.home.annexia.org>2009-07-07 16:55:51 +0100
committerRichard Jones <rjones@centos5x32.home.annexia.org>2009-07-07 16:55:51 +0100
commit157035503b509385084cafac8e5c5fa0afa2fef7 (patch)
tree8da2a2ca8e6c51afe1eb0adb40befedefe9676b8 /daemon/guestfsd.c
parent6fb57e430c8daa06d8d938ac02a104c8aadbbda5 (diff)
parentd5532e9ad29b28c2b323ad0abe4e0caa6e03f675 (diff)
downloadlibguestfs-157035503b509385084cafac8e5c5fa0afa2fef7.tar.gz
libguestfs-157035503b509385084cafac8e5c5fa0afa2fef7.tar.xz
libguestfs-157035503b509385084cafac8e5c5fa0afa2fef7.zip
Merge branch 'master' of git://git.et.redhat.com/libguestfs
Diffstat (limited to 'daemon/guestfsd.c')
-rw-r--r--daemon/guestfsd.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index e5f2cf0b..87065b9d 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
- * Copyright (C) 2009 Red Hat Inc.
+ * Copyright (C) 2009 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -572,19 +572,23 @@ commandrv (char **stdoutput, char **stderror, char * const* const argv)
* trailing \n characters from the error buffer (not from stdout).
*/
if (stdoutput) {
- *stdoutput = realloc (*stdoutput, so_size+1);
- if (*stdoutput == NULL) {
+ void *q = realloc (*stdoutput, so_size+1);
+ if (q == NULL) {
perror ("realloc");
- *stdoutput = NULL;
- } else
+ free (*stdoutput);
+ }
+ *stdoutput = q;
+ if (*stdoutput)
(*stdoutput)[so_size] = '\0';
}
if (stderror) {
- *stderror = realloc (*stderror, se_size+1);
- if (*stderror == NULL) {
+ void *q = realloc (*stderror, se_size+1);
+ if (q == NULL) {
perror ("realloc");
- *stderror = NULL;
- } else {
+ free (*stderror);
+ }
+ *stderror = q;
+ if (*stderror) {
(*stderror)[se_size] = '\0';
se_size--;
while (se_size >= 0 && (*stderror)[se_size] == '\n')