[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v2 03/10] libxl: json string object can be NULL



Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
 tools/libxl/libxl_json.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/libxl_json.c b/tools/libxl/libxl_json.c
index 346929a..652b3f4 100644
--- a/tools/libxl/libxl_json.c
+++ b/tools/libxl/libxl_json.c
@@ -433,8 +433,13 @@ int libxl__string_parse_json(libxl__gc *gc, const 
libxl__json_object *o,
 
     if (libxl__json_object_is_null(o))
         *p = NULL;
-    else
-        *p = libxl__strdup(NOGC, libxl__json_object_get_string(o));
+    else {
+        const char *s = libxl__json_object_get_string(o);
+        if (!s)
+            *p = NULL;
+        else
+            *p = libxl__strdup(NOGC, s);
+    }
 
     return 0;
 }
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.