From b690d679c1ca65d71b0544a2331d50e9f0f95116 Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Thu, 8 May 2014 18:03:15 +0200 Subject: Revert "qapi: Clean up superfluous null check in qapi_dealloc_type_str()" This reverts commit 25a7017555f1b4aeb543b5d323ff4afb8f9c5437. Turns out the argument *can* be null: QEMU now segfaults if it receives an invalid parameter via a qmp command instead of throwing an error. For example: { "execute": "blockdev-add", "arguments": { "options" : { "driver": "invalid-driver" } } } CC: qemu-stable@nongnu.org Signed-off-by: Peter Lieven Reviewed-by: Eric Blake Reviewed-by: Markus Armbruster Signed-off-by: Luiz Capitulino --- qapi/qapi-dealloc-visitor.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'qapi/qapi-dealloc-visitor.c') diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c index d0ea118fe3..dc53545fa5 100644 --- a/qapi/qapi-dealloc-visitor.c +++ b/qapi/qapi-dealloc-visitor.c @@ -131,7 +131,9 @@ static void qapi_dealloc_end_list(Visitor *v, Error **errp) static void qapi_dealloc_type_str(Visitor *v, char **obj, const char *name, Error **errp) { - g_free(*obj); + if (obj) { + g_free(*obj); + } } static void qapi_dealloc_type_int(Visitor *v, int64_t *obj, const char *name, -- cgit v1.2.3