[Libvir] [PATCH] Avoid segfault upon early libvirtd failure.

Jim Meyering jim at meyering.net
Mon Mar 3 16:10:28 UTC 2008

One of today's leak-plugging patches introduced a bug.
Fortunately, it can strike only when libvirtd is about to
fail anyway.  The consequence is that instead of failing in
an orderly manner, it would probably segfault.

Sorry about that.  Here's the fix:

	Avoid segfault upon early libvirtd failure.
	* qemud/qemud.c (main): Don't call qemudCleanup on an
	uninitialized pointer.

By the way, even though this evoked a warning from gcc,
"make distcheck" passes.  Obviously, that means the distcheck
rule is inadequate.  I'll fix it so that it turns on -Werror
for the final build.

Signed-off-by: Jim Meyering <meyering at redhat.com>
 qemud/qemud.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/qemud/qemud.c b/qemud/qemud.c
index 96fdf32..b6b82ed 100644
--- a/qemud/qemud.c
+++ b/qemud/qemud.c
@@ -2025,7 +2025,7 @@ libvirt management daemon:\n\

 #define MAX_LISTEN 5
 int main(int argc, char **argv) {
-    struct qemud_server *server;
+    struct qemud_server *server = NULL;
     struct sigaction sig_action;
     int sigpipe[2];
     const char *pid_file = NULL;
@@ -2180,7 +2180,8 @@ int main(int argc, char **argv) {
         unlink (pid_file);

-    qemudCleanup(server);
+    if (server)
+        qemudCleanup(server);
     return ret;


More information about the libvir-list mailing list