From e0004d19ad498e5ab176252194eb79ec0c8395bd Mon Sep 17 00:00:00 2001 From: "ky85.kim" Date: Mon, 23 May 2016 20:44:36 +0900 Subject: [PATCH] Fix SVACE - memory leak Change-Id: I0a6fa091655dab038d00bb4297b6c09b1566e2fa Signed-off-by: ky85.kim --- client/stt_client.c | 7 ++++++- client/stt_dbus.c | 22 +++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/client/stt_client.c b/client/stt_client.c index 9244b87..d5a45b4 100644 --- a/client/stt_client.c +++ b/client/stt_client.c @@ -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 +} diff --git a/client/stt_dbus.c b/client/stt_dbus.c index 754bd3e..5a8f2f4 100644 --- a/client/stt_dbus.c +++ b/client/stt_dbus.c @@ -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; -- 2.7.4