lib: Fix memory leak when debugging enabled (found by valgrind).
authorRichard W.M. Jones <rjones@redhat.com>
Thu, 24 Nov 2011 15:50:54 +0000 (15:50 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Thu, 24 Nov 2011 21:07:29 +0000 (21:07 +0000)
If you enabled debugging (eg. LIBGUESTFS_DEBUG=1) then every
debug message printed would be leaked.
(cherry picked from commit dd76ce2b4c93dd10d8eca9ab7c77bc831f103d03)

src/guestfs.c

index f4b79e7..450ffd8 100644 (file)
@@ -373,6 +373,8 @@ guestfs___debug (guestfs_h *g, const char *fs, ...)
   if (len < 0) return;
 
   guestfs___call_callbacks_message (g, GUESTFS_EVENT_LIBRARY, msg, len);
+
+  free (msg);
 }
 
 /* Call trace messages.  These are enabled by setting g->trace, and