Fix memory leaks of dbus 55/167955/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Mon, 22 Jan 2018 11:41:27 +0000 (20:41 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Tue, 23 Jan 2018 05:38:12 +0000 (05:38 +0000)
Change-Id: I006f65e913f87b877638c90c5e3860066a3c1491
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
(cherry picked from commit 2d32797ba7e37ec153e6784dfe1ab0c9ef453d7b)

client/tts_dbus.c
server/ttsd_dbus.c

index f922798..296bc44 100644 (file)
@@ -158,10 +158,12 @@ static void __tts_dbus_connection_free()
 {
        if (NULL != g_conn_listener) {
                dbus_connection_close(g_conn_listener);
+               dbus_connection_unref(g_conn_listener);
                g_conn_listener = NULL;
        }
        if (NULL != g_conn_sender) {
                dbus_connection_close(g_conn_sender);
+               dbus_connection_unref(g_conn_sender);
                g_conn_sender = NULL;
        }
 }
@@ -299,27 +301,27 @@ DBusMessage* __tts_dbus_make_message(int uid, const char* method)
 
        if (TTS_MODE_DEFAULT == client->mode) {
                msg = dbus_message_new_method_call(
-                       TTS_SERVER_SERVICE_NAME, 
-                       TTS_SERVER_SERVICE_OBJECT_PATH, 
-                       TTS_SERVER_SERVICE_INTERFACE, 
+                       TTS_SERVER_SERVICE_NAME,
+                       TTS_SERVER_SERVICE_OBJECT_PATH,
+                       TTS_SERVER_SERVICE_INTERFACE,
                        method);
        } else if (TTS_MODE_NOTIFICATION == client->mode) {
                msg = dbus_message_new_method_call(
-                       TTS_NOTI_SERVER_SERVICE_NAME, 
-                       TTS_NOTI_SERVER_SERVICE_OBJECT_PATH, 
-                       TTS_NOTI_SERVER_SERVICE_INTERFACE, 
+                       TTS_NOTI_SERVER_SERVICE_NAME,
+                       TTS_NOTI_SERVER_SERVICE_OBJECT_PATH,
+                       TTS_NOTI_SERVER_SERVICE_INTERFACE,
                        method);
        } else if (TTS_MODE_SCREEN_READER == client->mode) {
                msg = dbus_message_new_method_call(
-                       TTS_SR_SERVER_SERVICE_NAME, 
-                       TTS_SR_SERVER_SERVICE_OBJECT_PATH, 
-                       TTS_SR_SERVER_SERVICE_INTERFACE, 
+                       TTS_SR_SERVER_SERVICE_NAME,
+                       TTS_SR_SERVER_SERVICE_OBJECT_PATH,
+                       TTS_SR_SERVER_SERVICE_INTERFACE,
                        method);
        } else if (TTS_MODE_INTERRUPT == client->mode) {
                msg = dbus_message_new_method_call(
-                       TTS_INTERRUPT_SERVER_SERVICE_NAME, 
-                       TTS_INTERRUPT_SERVER_SERVICE_OBJECT_PATH, 
-                       TTS_INTERRUPT_SERVER_SERVICE_INTERFACE, 
+                       TTS_INTERRUPT_SERVER_SERVICE_NAME,
+                       TTS_INTERRUPT_SERVER_SERVICE_OBJECT_PATH,
+                       TTS_INTERRUPT_SERVER_SERVICE_INTERFACE,
                        method);
        } else {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input mode is not available");
index 9e0c4f1..1cf564b 100644 (file)
@@ -75,9 +75,9 @@ int ttsdc_send_hello(int pid, int uid)
 
        /* create a message & check for errors */
        msg = dbus_message_new_method_call(
-               service_name, 
-               TTS_CLIENT_SERVICE_OBJECT_PATH, 
-               target_if_name, 
+               service_name,
+               TTS_CLIENT_SERVICE_OBJECT_PATH,
+               target_if_name,
                TTSD_METHOD_HELLO);
 
        if (NULL == msg) {
@@ -312,10 +312,12 @@ void __ttsd_dbus_connection_free()
 {
        if (NULL != g_conn_listener) {
                dbus_connection_close(g_conn_listener);
+               dbus_connection_unref(g_conn_listener);
                g_conn_listener = NULL;
        }
        if (NULL != g_conn_sender) {
                dbus_connection_close(g_conn_sender);
+               dbus_connection_unref(g_conn_sender);
                g_conn_sender = NULL;
        }
 }