xl: fix a couple of memory leaks
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 27 Jan 2012 17:01:19 +0000 (17:01 +0000)
committerIan Jackson <ian.jackson@eu.citrix.com>
Fri, 27 Jan 2012 17:01:19 +0000 (17:01 +0000)
* dolog leaked the log message (!)

* main() leaked the config_data (perhaps a false positive from valgrind,
  but it's nicer to tidy it up).

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
tools/libxl/xl.c
tools/libxl/xl_cmdimpl.c

index 7b9d2c855a222a273e60477a76649ced0693ca4c..02a680326f2ac6ec429a2fcda9da6e019dc435b4 100644 (file)
@@ -135,6 +135,7 @@ int main(int argc, char **argv)
                 config_file, strerror(errno));
     parse_global_config(config_file, config_data, config_len);
     free(config_file);
+    free(config_data);
 
     /* Reset options for per-command use of getopt. */
     argv += optind;
index 16fc5bf9b70285c1668e1a293dbbe98c3656cfab..5c4dfe3684a3d5f9343441cf3f7b0d45da36e95c 100644 (file)
@@ -278,7 +278,7 @@ static void dolog(const char *file, int line, const char *func, char *fmt, ...)
 static void dolog(const char *file, int line, const char *func, char *fmt, ...)
 {
     va_list ap;
-    char *s;
+    char *s = NULL;
     int rc;
 
     va_start(ap, fmt);
@@ -286,6 +286,7 @@ static void dolog(const char *file, int line, const char *func, char *fmt, ...)
     va_end(ap);
     if (rc >= 0)
         libxl_write_exactly(NULL, logfile, s, rc, NULL, NULL);
+    free(s);
 }
 
 static void printf_info(int domid,