unref message when fail to set_notify or when not completed.
authorbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 28 Aug 2009 16:54:19 +0000 (16:54 +0000)
committerbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 28 Aug 2009 16:54:19 +0000 (16:54 +0000)
Hey folks,

Regarding edbus, I believe that when sending a message, if it fails to
set_notify, it should cancel and unref the pending message. Another
thing, if the pending call doesn't complete, it should free data and
unref it too, right?

I'm attaching a small patch to fix it.

Please, somebody take a look at that when have some time.

Thanks,

By: Bruno Dilly <bdilly@profusion.mobi>

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/e_dbus@42081 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/dbus/e_dbus_message.c

index b77aa9f..ada0234 100644 (file)
@@ -19,6 +19,9 @@ cb_pending(DBusPendingCall *pending, void *user_data)
   if (!dbus_pending_call_get_completed(pending))
   {
     printf("NOT COMPLETED\n");
+    free(data);
+    dbus_message_unref(msg);
+    dbus_pending_call_unref(pending);
     return;
   }
 
@@ -77,7 +80,12 @@ e_dbus_message_send(E_DBus_Connection *conn, DBusMessage *msg, E_DBus_Method_Ret
     pdata->data = data;
 
     if (!dbus_pending_call_set_notify(pending, cb_pending, pdata, free))
+    {
       free(pdata);
+      dbus_message_unref(msg);
+      dbus_pending_call_cancel(pending);
+      return NULL;
+    }
   }
 
   return pending;