eldbus: add dbus_pending NULL check
authorThiep Ha <thiep.ha@samsung.com>
Wed, 23 Sep 2015 00:19:59 +0000 (09:19 +0900)
committerChunEon Park <hermet@hermet.pe.kr>
Wed, 23 Sep 2015 00:22:51 +0000 (09:22 +0900)
Summary:
When we call dbus_connection_send_with_reply, the dbus_pending
can be NULL. In this case, the next call dbus_pending_call_set_notify
will cause application crash.
We should check if dbus_pending is NULL before calling dbus API.

@fix

Reviewers: cedric

Subscribers: englebass, cedric, seoz

Differential Revision: https://phab.enlightenment.org/D3081

src/lib/eldbus/eldbus_pending.c

index fa68d03..69ea322 100644 (file)
@@ -157,6 +157,13 @@ _eldbus_connection_send(Eldbus_Connection *conn, Eldbus_Message *msg, Eldbus_Mes
         eldbus_pending_dispatch(pending, error_msg);
         return NULL;
      }
+   if (!pending->dbus_pending)
+     {
+        error_msg = eldbus_message_error_new(msg, "org.enlightenment.DBus.Error",
+                                             "dbus_pending is NULL.");
+        eldbus_pending_dispatch(pending, error_msg);
+        return NULL;
+     }
    if (dbus_pending_call_set_notify(pending->dbus_pending, cb_pending, pending, NULL))
      return pending;
 
@@ -238,7 +245,8 @@ eldbus_pending_dispatch(Eldbus_Pending *pending, Eldbus_Message *msg)
 
    if (msg) eldbus_message_unref(msg);
    eldbus_message_unref(pending->msg_sent);
-   dbus_pending_call_unref(pending->dbus_pending);
+   if (pending->dbus_pending)
+     dbus_pending_call_unref(pending->dbus_pending);
 
    pending->cb = NULL;
    pending->dbus_pending = NULL;