From b774539743c52ef605c6e2cbac19376c2757cb86 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 1 Mar 2014 08:40:39 +0100 Subject: qapi: Add missing null check to opts_start_struct() 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 Reviewed-by: Eric Blake Signed-off-by: Luiz Capitulino --- qapi/opts-visitor.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c index 96ed85899d..5d830a2b56 100644 --- a/qapi/opts-visitor.c +++ b/qapi/opts-visitor.c @@ -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; } -- cgit v1.2.3