Fix reference null bug 94/220194/4
authorhyunho <hhstark.kang@samsung.com>
Mon, 16 Dec 2019 03:59:10 +0000 (12:59 +0900)
committerhyunho <hhstark.kang@samsung.com>
Mon, 16 Dec 2019 04:26:03 +0000 (13:26 +0900)
Change-Id: Ifaaa0edadf582b86321ebf8dee79c27d28c2b82e
Signed-off-by: hyunho <hhstark.kang@samsung.com>
src/fdbroker-internal.cc

index 376c2c7..6dd0c62 100644 (file)
@@ -759,22 +759,25 @@ void FdBroker::OnResultReceived(GObject* source_object,
   GError* err = nullptr;
   GDBusMessage* reply = g_dbus_connection_send_message_with_reply_finish(conn,
       res, &err);
-  if (reply == nullptr) {
-    LOGE("No reply. err(%s)", err ? err->message : "Unknown");
-    if (err && err->code == G_IO_ERROR_CANCELLED) {
-      g_error_free(err);
-      return;
-    }
+
+  if (err && err->code == G_IO_ERROR_CANCELLED) {
+    g_error_free(err);
+    LOGE("IO error cancelled");
+    return;
   }
 
   FdBroker* broker = static_cast<FdBroker*>(user_data);
+  if (broker == nullptr) {
+      LOGW("Null broker");
+      return;
+  }
   IEventWatcher* watcher = broker->watcher_;
 
   if (err) {
     watcher->OnPortDisconnected(broker->watch_appid_, broker->watch_port_name_,
         true);
     g_error_free(err);
-    if (broker && broker->cancellable_) {
+    if (broker->cancellable_) {
       LOGW("Cancel the send request");
       g_cancellable_cancel(broker->cancellable_);
       g_object_unref(broker->cancellable_);
@@ -783,6 +786,11 @@ void FdBroker::OnResultReceived(GObject* source_object,
     return;
   }
 
+  if (reply == nullptr) {
+    LOGW("Null reply");
+    return;
+  }
+
   GVariant* reply_body = g_dbus_message_get_body(reply);
   if (reply_body == nullptr) {
     LOGE("g_dbus_message_get_body() is failed");