]> xenbits.xensource.com Git - xen.git/commitdiff
xl: use xrealloc in domain create
authorIan Campbell <ian.campbell@citrix.com>
Wed, 17 Feb 2016 14:04:14 +0000 (14:04 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 19 Feb 2016 16:02:51 +0000 (16:02 +0000)
Using bare realloc risks leaking the old pointer if the realloc fails.

Since xrealloc exits on such failures, drop the error handling.

Noticed while fixing, but not related to, CID 1055898.

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

index d07ccb2a5e34a5574fd40c911df8a7a635c203a2..2271e757c18dd8e70ae02a7f3a6b55a733236617 100644 (file)
@@ -2793,12 +2793,8 @@ static uint32_t create_domain(struct domain_create *dom_info)
                 return ERROR_FAIL;
             }
             /* allocate space for the extra config plus two EOLs plus \0 */
-            config_data = realloc(config_data, config_len
+            config_data = xrealloc(config_data, config_len
                 + strlen(extra_config) + 2 + 1);
-            if (!config_data) {
-                fprintf(stderr, "Failed to realloc config_data\n");
-                return ERROR_FAIL;
-            }
             config_len += sprintf(config_data + config_len, "\n%s\n",
                 extra_config);
         }