Fix SVACE - memory leak 68/70968/1
authorky85.kim <ky85.kim@samsung.com>
Mon, 23 May 2016 11:44:36 +0000 (20:44 +0900)
committerky85.kim <ky85.kim@samsung.com>
Mon, 23 May 2016 11:45:06 +0000 (20:45 +0900)
Change-Id: I0a6fa091655dab038d00bb4297b6c09b1566e2fa
Signed-off-by: ky85.kim <ky85.kim@samsung.com>
client/stt_client.c
client/stt_dbus.c

index 9244b87..d5a45b4 100644 (file)
@@ -70,6 +70,7 @@ int stt_client_new(stt_h* stt)
        client->default_lang_changed_user_data = NULL;
 
        client->current_engine_id = NULL;
+       client->credential = NULL;
 
        client->silence_supported = false;
        client->silence = STT_OPTION_SILENCE_DETECTION_AUTO;
@@ -128,6 +129,10 @@ int stt_client_destroy(stt_h stt)
                                        free(data->err_msg);
                                }
 
+                               if (NULL != data->credential) {
+                                       free(data->credential);
+                               }
+
                                free(data);
                                free(stt);
 
@@ -230,4 +235,4 @@ int stt_client_get_use_callback(stt_client_s* client)
 GList* stt_client_get_client_list()
 {
        return g_client_list;
-}
\ No newline at end of file
+}
index 754bd3e..5a8f2f4 100644 (file)
@@ -1233,8 +1233,12 @@ int stt_dbus_request_start(int uid, const char* lang, const char* type, int sile
                SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt start : uid(%d), language(%s), type(%s)", uid, lang, type);
        }
 
-       if (NULL == credential)
-               credential = strdup("NULL");
+       char *temp = NULL;
+       if (NULL == credential) {
+               temp = strdup("NULL");
+       } else {
+               temp = strdup(credential);
+       }
 
        dbus_message_append_args(msg,
                DBUS_TYPE_INT32, &uid,
@@ -1242,7 +1246,7 @@ int stt_dbus_request_start(int uid, const char* lang, const char* type, int sile
                DBUS_TYPE_STRING, &type,
                DBUS_TYPE_INT32, &silence,
                DBUS_TYPE_STRING, &appid,
-               DBUS_TYPE_STRING, &credential,
+               DBUS_TYPE_STRING, &temp,
                DBUS_TYPE_INVALID);
 #if 1
        if (g_conn_sender) {
@@ -1250,6 +1254,10 @@ int stt_dbus_request_start(int uid, const char* lang, const char* type, int sile
 
                if (!dbus_connection_send(g_conn_sender, msg, NULL)) {
                        SLOG(LOG_ERROR, TAG_STTC, "[Dbus ERROR] <<<< stt start message : Out Of Memory !");
+                       if (NULL != temp) {
+                                       free(temp);
+                                       temp = NULL;
+                       }
                        return STT_ERROR_OUT_OF_MEMORY;
                } else {
                        dbus_connection_flush(g_conn_sender);
@@ -1259,9 +1267,17 @@ int stt_dbus_request_start(int uid, const char* lang, const char* type, int sile
 
        } else {
                SLOG(LOG_WARN, TAG_STTC, "[WARN] dbus connection handle is null (%p)", g_conn_sender);
+               if (NULL != temp) {
+                               free(temp);
+                               temp = NULL;
+               }
                return STT_ERROR_OPERATION_FAILED;
        }
 
+       if (NULL != temp) {
+                       free(temp);
+                       temp = NULL;
+       }
        return 0;
 #else
        DBusError err;