]> xenbits.xensource.com Git - xen.git/commitdiff
xl: use xstrdup in cpurange_parse
authorWei Liu <wei.liu2@citrix.com>
Wed, 25 May 2016 13:23:56 +0000 (14:23 +0100)
committerWei Liu <wei.liu2@citrix.com>
Wed, 25 May 2016 13:42:35 +0000 (14:42 +0100)
This ensures buf is always valid when it is passed to strtok_r.

CID: 1291936

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libxl/xl_cmdimpl.c

index 03ab644caef255874042759ab4af8958455c093e..d8530f00b17324d2ae3223974d8c5928888fb3f6 100644 (file)
@@ -847,7 +847,7 @@ static int update_cpumap_range(const char *str, libxl_bitmap *cpumap)
  */
 static int cpurange_parse(const char *cpu, libxl_bitmap *cpumap)
 {
-    char *ptr, *saveptr = NULL, *buf = strdup(cpu);
+    char *ptr, *saveptr = NULL, *buf = xstrdup(cpu);
     int rc = 0;
 
     for (ptr = strtok_r(buf, ",", &saveptr); ptr;