Skip to contentSkip to conversation

Revert "qapi: Clean up superfluous null check in qapi_dealloc_type_str()"

PATCH Applied Peter Lieven 2 participants 2 messages May 8, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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" } } }
---
 qapi/qapi-dealloc-visitor.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
qapi/qapi-dealloc-visitor.c +3 -1
index d0ea118..dc53545 100644
@@ -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,
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 6 lines · On Thu, 8 May 2014 18:03:15 +0200 Peter Lieven <[email protected]> wrote:

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.

Quoted 8 lines

For example:
{ "execute": "blockdev-add",

     "arguments": { "options" : { "driver": "invalid-driver" } } }

Applied to the qmp branch, thanks.

Quoted 19 lines
---
 qapi/qapi-dealloc-visitor.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
qapi/qapi-dealloc-visitor.c +3 -1
index d0ea118..dc53545 100644
@@ -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,