Fix double free issue of eldbus connection 75/96575/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Wed, 9 Nov 2016 10:30:13 +0000 (19:30 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Wed, 9 Nov 2016 10:31:36 +0000 (19:31 +0900)
Change-Id: I6cc36986623ab57a8f6b5577e5465e9f58fabf50
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
scl/gwes/efl/sclevents-efl.cpp

index 97fb2ce..a850a9e 100644 (file)
@@ -47,7 +47,7 @@ using namespace scl;
 #define E_KEYBOARD_SERVICE_BUS_NAME "org.tizen.keyboard"
 #define E_KEYBOARD_SERVICE_NAVI_IFC_NAME "org.tizen.KBGestureNavigation"
 #define E_KEYBOARD_SERVICE_NAVI_OBJ_PATH "/org/tizen/KBGestureNavigation"
-static Eldbus_Connection *conn = NULL;
+static Eldbus_Connection *eldbus_conn = NULL;
 typedef enum _Gesture {
      ONE_FINGER_HOVER = 0,
      ONE_FINGER_SINGLE_TAP = 15,
@@ -228,32 +228,34 @@ static void gesture_cb(void *data, const Eldbus_Message *msg)
 
 void gestures_tracker_register()
 {
-        Eldbus_Object *obj;
-        Eldbus_Proxy *proxy;
-
-        eldbus_init();
-        LOGD("Registering callback for GestureDetected signal");
-        if (!(conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION))) {
-                LOGD("Error: Unable to get session bus");
-                return;
-        }
-        obj = eldbus_object_get(conn, E_KEYBOARD_SERVICE_BUS_NAME, E_KEYBOARD_SERVICE_NAVI_OBJ_PATH);
-        if (!obj) LOGD("Error: Getting object failed");
-
-        proxy = eldbus_proxy_get(obj, E_KEYBOARD_SERVICE_NAVI_IFC_NAME);
-        if (!proxy) LOGD("Error: Getting proxy failed");
-        if (!eldbus_proxy_signal_handler_add(proxy, "KBGestureDetected", gesture_cb, NULL))
-                LOGD("No signal handler returned");
-        LOGD("Callback registration successful");
+    Eldbus_Object *obj;
+    Eldbus_Proxy *proxy;
+
+    eldbus_init();
+    LOGD("Registering callback for GestureDetected signal");
+    if (!(eldbus_conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION))) {
+        LOGD("Error: Unable to get session bus");
         return;
+    }
+    obj = eldbus_object_get(eldbus_conn, E_KEYBOARD_SERVICE_BUS_NAME, E_KEYBOARD_SERVICE_NAVI_OBJ_PATH);
+    if (!obj) LOGD("Error: Getting object failed");
+
+    proxy = eldbus_proxy_get(obj, E_KEYBOARD_SERVICE_NAVI_IFC_NAME);
+    if (!proxy) LOGD("Error: Getting proxy failed");
+    if (!eldbus_proxy_signal_handler_add(proxy, "KBGestureDetected", gesture_cb, NULL))
+        LOGD("No signal handler returned");
+    LOGD("Callback registration successful");
+    return;
 }
 
 void gestures_tracker_unregister()
 {
-   if (conn)
-      eldbus_connection_unref(conn);
+    if (eldbus_conn) {
+        eldbus_connection_unref(eldbus_conn);
+        eldbus_conn = NULL;
+    }
 
-   eldbus_shutdown();
+    eldbus_shutdown();
 }
 #endif
 /**