Message ID | 1304090522-5861-3-git-send-email-mdroth@linux.vnet.ibm.com |
---|---|
State | New |
Headers | show |
diff --git a/qapi/qmp-input-visiter.c b/qapi/qmp-input-visiter.c index 53379fd..4bae85e 100644 --- a/qapi/qmp-input-visiter.c +++ b/qapi/qmp-input-visiter.c @@ -75,7 +75,9 @@ static void qmp_input_start_struct(Visiter *v, void **obj, const char *kind, con qmp_input_push(qiv, qobj); - *obj = qemu_mallocz(QAPI_OBJECT_SIZE); + if (obj) { + *obj = qemu_mallocz(QAPI_OBJECT_SIZE); + } } static void qmp_input_end_struct(Visiter *v, Error **errp)
Sometimes we have anonymous nested structs rather than references. In these cases we call visit_start_struct() primarilly to push the nested qobject onto the stack, and specify a NULL obj value to avoid doing any memory allocation. So add a simple check for this NULL value. Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> --- qapi/qmp-input-visiter.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)