Skip to contentSkip to conversation

Monitor: Fix command execution regression

PATCH Applied Luiz Capitulino 2 participants 2 messages Jan 27, 2010 – Jan 28, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Monitor: Fix command execution regression

Function is_async_return() added by commit 940cc30d0d4 assumes that 'data', which is returned by handlers, is always a QDict.

This is not true, as QLists can also be returned, in this case we'll get a segfault.

Fix that by checking if 'data' is a QDict.

---
 monitor.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
monitor.c +5 -1
index fbae5ce..fb7c572 100644
@@ -3700,7 +3700,11 @@ static void monitor_print_error(Monitor *mon)
 
 static int is_async_return(const QObject *data)
 {
-    return data && qdict_haskey(qobject_to_qdict(data), "__mon_async");
+    if (data && qobject_type(data) == QTYPE_QDICT) {
+        return qdict_haskey(qobject_to_qdict(data), "__mon_async");
+    }
+
+    return 0;
 }
 
 static void monitor_call_handler(Monitor *mon, const mon_cmd_t *cmd,
Signature · 1 line
1.6.6
Applied
#1 lore raw

Thanks, applied.

Quoted 37 lines · Luiz Capitulino

Function is_async_return() added by commit 940cc30d0d4 assumes that 'data', which is returned by handlers, is always a QDict.

This is not true, as QLists can also be returned, in this case we'll get a segfault.

Fix that by checking if 'data' is a QDict.

---
 monitor.c |    6 +++++-

 1 files changed, 5 insertions(+), 1 deletions(-)
monitor.c +5 -2
index fbae5ce..fb7c572 100644
@@ -3700,7 +3700,11 @@ static void monitor_print_error(Monitor *mon)
 
  static int is_async_return(const QObject *data)
  {
-    return data && qdict_haskey(qobject_to_qdict(data), "__mon_async");
+    if (data && qobject_type(data) == QTYPE_QDICT) {
+        return qdict_haskey(qobject_to_qdict(data), "__mon_async");
+    }
+
+    return 0;
  }
 
  static void monitor_call_handler(Monitor *mon, const mon_cmd_t *cmd,
--

1.6.6