Fix memory leak in ibus-daemon
authorPeng Huang <shawn.p.huang@gmail.com>
Fri, 28 Aug 2009 03:36:28 +0000 (11:36 +0800)
committerPeng Huang <shawn.p.huang@gmail.com>
Fri, 28 Aug 2009 03:36:28 +0000 (11:36 +0800)
bus/engineproxy.c

index 5c18149d29ec8c7e685acd48e509588e6269adb1..70e11744961a871f5e22c2ff6e9052ab3bf68f83 100644 (file)
@@ -534,20 +534,17 @@ bus_engine_proxy_process_key_event_reply_cb (IBusPendingCall *pending,
 {
     IBusMessage *reply_message;
     IBusError *error;
-    gboolean retval;
+    gboolean retval = FALSE;
 
     reply_message = dbus_pending_call_steal_reply (pending);
 
     if (reply_message == NULL) {
-        call_data->func(FALSE, call_data->user_data);
-        return;
+        goto _out;
     }
     else if ((error = ibus_error_new_from_message (reply_message)) != NULL) {
         g_warning ("%s: %s", error->name, error->message);
-        ibus_message_unref (reply_message);
         ibus_error_free (error);
-        call_data->func(FALSE, call_data->user_data);
-        return;
+        goto _out;
     }
 
     if (!ibus_message_get_args (reply_message,
@@ -555,12 +552,14 @@ bus_engine_proxy_process_key_event_reply_cb (IBusPendingCall *pending,
                                 G_TYPE_BOOLEAN, &retval,
                                 G_TYPE_INVALID)) {
         g_warning ("%s: %s", error->name, error->message);
-        ibus_message_unref (reply_message);
         ibus_error_free (error);
-        call_data->func (GINT_TO_POINTER (FALSE), call_data->user_data);
-        return;
+        goto _out;
     }
 
+_out:
+    if (reply_message) {
+        ibus_message_unref (reply_message);
+    }
     call_data->func (GINT_TO_POINTER (retval), call_data->user_data);
     g_slice_free (CallData, call_data);
 }