qapi: Add missing null check to opts_start_struct()
authorMarkus Armbruster <armbru@redhat.com>
Sat, 1 Mar 2014 07:40:39 +0000 (08:40 +0100)
committerLuiz Capitulino <lcapitulino@redhat.com>
Mon, 3 Mar 2014 16:17:45 +0000 (11:17 -0500)
Argument is null when visiting an unboxed struct.  I can't see such a
visit in the current code.  Fix it anyway.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
qapi/opts-visitor.c

index 96ed85899d596e81306c8213ac4b0f147fe4ec5d..5d830a2b56d70e1a8fddf0f4aa9ecb75331941be 100644 (file)
@@ -124,7 +124,9 @@ opts_start_struct(Visitor *v, void **obj, const char *kind,
     OptsVisitor *ov = DO_UPCAST(OptsVisitor, visitor, v);
     const QemuOpt *opt;
 
-    *obj = g_malloc0(size > 0 ? size : 1);
+    if (obj) {
+        *obj = g_malloc0(size > 0 ? size : 1);
+    }
     if (ov->depth++ > 0) {
         return;
     }