Patchwork QMP: Don't free async event's 'data'

login
register
mail settings
Submitter Luiz Capitulino
Date Jan. 8, 2010, 6:45 p.m.
Message ID <20100108164553.0ad0fb5d@doriath>
Download mbox | patch
Permalink /patch/42532/
State New
Headers show

Comments

Luiz Capitulino - Jan. 8, 2010, 6:45 p.m.
The monitor_protocol_event() function will free the
event's data, this is wrong as 'data' management is up
to the caller.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
Anthony Liguori - Jan. 12, 2010, 7:35 p.m.
On 01/08/2010 12:45 PM, Luiz Capitulino wrote:
> The monitor_protocol_event() function will free the
> event's data, this is wrong as 'data' management is up
> to the caller.
>
> Signed-off-by: Luiz Capitulino<lcapitulino@redhat.com>
>    

Applied.  Thanks.

Regards,

Anthony Liguori

> ---
>   monitor.c |    4 +++-
>   1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index 3af1d5c..2403a97 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -365,8 +365,10 @@ void monitor_protocol_event(MonitorEvent event, QObject *data)
>       qmp = qdict_new();
>       timestamp_put(qmp);
>       qdict_put(qmp, "event", qstring_from_str(event_name));
> -    if (data)
> +    if (data) {
> +        qobject_incref(data);
>           qdict_put_obj(qmp, "data", data);
> +    }
>
>       monitor_json_emitter(mon, QOBJECT(qmp));
>       QDECREF(qmp);
>

Patch

diff --git a/monitor.c b/monitor.c
index 3af1d5c..2403a97 100644
--- a/monitor.c
+++ b/monitor.c
@@ -365,8 +365,10 @@  void monitor_protocol_event(MonitorEvent event, QObject *data)
     qmp = qdict_new();
     timestamp_put(qmp);
     qdict_put(qmp, "event", qstring_from_str(event_name));
-    if (data)
+    if (data) {
+        qobject_incref(data);
         qdict_put_obj(qmp, "data", data);
+    }
 
     monitor_json_emitter(mon, QOBJECT(qmp));
     QDECREF(qmp);