]> xenbits.xensource.com Git - xen.git/commitdiff
xl: correct handling of extra_config in main_cpupoolcreate
authorWei Liu <wei.liu2@citrix.com>
Tue, 14 Jul 2015 16:41:10 +0000 (17:41 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 11 Sep 2015 10:56:56 +0000 (11:56 +0100)
Don't dereference extra_config if it's NULL. Don't leak extra_config in
the end.

Also fixed a typo in error string while I was there.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
(cherry picked from commit 705c9e12426cba82804cb578fc70785281655d94)
(cherry picked from commit ffb4e6387f489b6b5ce287f51db43cb37ebae064)
(cherry picked from commit 213e243819ba5f72e13afad41ce2f5df17715530)

tools/libxl/xl_cmdimpl.c

index 55b406496457df428f551abaafeb514e3ceec494..784f676d575bbb13cdfe0205b171a8c55ca7e7e8 100644 (file)
@@ -6412,9 +6412,9 @@ int main_cpupoolcreate(int argc, char **argv)
     else
         config_src="command line";
 
-    if (strlen(extra_config)) {
+    if (extra_config && strlen(extra_config)) {
         if (config_len > INT_MAX - (strlen(extra_config) + 2)) {
-            fprintf(stderr, "Failed to attach extra configration\n");
+            fprintf(stderr, "Failed to attach extra configuration\n");
             goto out;
         }
         config_data = xrealloc(config_data,
@@ -6537,6 +6537,7 @@ out_cfg:
     xlu_cfg_destroy(config);
 out:
     free(config_data);
+    free(extra_config);
     return rc;
 }