fix svace issues 21/126121/2 accepted/tizen/unified/20170420.155746 submit/tizen/20170420.093216
authorKyeonghun Lee <kh9090.lee@samsung.com>
Thu, 20 Apr 2017 07:20:09 +0000 (16:20 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Thu, 20 Apr 2017 09:43:40 +0000 (18:43 +0900)
Change-Id: I28f2db90fe026795c1892ee29982a68a22efff62
Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
email-core/email-storage/email-storage.c
email-daemon/email-daemon-mail.c

index d29f960..5c2c152 100755 (executable)
@@ -1143,6 +1143,7 @@ static int _get_table_field_data_string(char **table, char **buf, int ucs2, int
                                goto FINISH_OFF;
                        }
                        strncpy(*buf, pTemp, sLen);
+                       (*buf)[sLen] = '\0';
                } else
                        *buf = NULL;
        }
@@ -1400,7 +1401,7 @@ static int _bind_stmt_field_data_string(DB_STMT hStmt, int index, char *value, i
        if (value != NULL)
                ret = sqlite3_bind_text(hStmt, index+1, value, -1, SQLITE_STATIC);
        else
-               ret = sqlite3_bind_text(hStmt, index+1, "", -1, NULL);
+               ret = sqlite3_bind_text(hStmt, index+1, "", -1, SQLITE_STATIC);
 
        if (ret != SQLITE_OK) {
                EM_DEBUG_EXCEPTION("sqlite3_bind_text fail [%d]", ret);
@@ -1409,15 +1410,6 @@ static int _bind_stmt_field_data_string(DB_STMT hStmt, int index, char *value, i
        return true;
 }
 
-/* destroy function for sqlite3_bind_text */
-void _bind_stmt_free_string(void* arg)
-{
-       EM_DEBUG_FUNC_BEGIN();
-       char* p = (char*) arg;
-       EM_SAFE_FREE(p);
-       EM_DEBUG_FUNC_END();
-}
-
 static int _bind_stmt_field_data_nstring(DB_STMT hStmt, int index, char *value, int ucs2, int max_len)
 {
        if ((hStmt == NULL) || (index < 0)) {
@@ -1440,10 +1432,11 @@ static int _bind_stmt_field_data_nstring(DB_STMT hStmt, int index, char *value,
                                return false;
                        }
                        snprintf(buf, max_len-1, "%s", value);
-                       ret = sqlite3_bind_text(hStmt, index+1, buf, -1, _bind_stmt_free_string);
+                       ret = sqlite3_bind_text(hStmt, index+1, buf, -1, SQLITE_TRANSIENT);
+                       g_free(buf);
                }
        } else
-               ret = sqlite3_bind_text(hStmt, index+1, "", -1, NULL);
+               ret = sqlite3_bind_text(hStmt, index+1, "", -1, SQLITE_STATIC);
 
        if (ret != SQLITE_OK) {
                EM_DEBUG_EXCEPTION("sqlite3_bind_text fail [%d]", ret);
index 175e421..d4dce4d 100755 (executable)
@@ -731,7 +731,8 @@ FINISH_OFF:
        thread_func_event_data->multi_user_name = g_strdup(multi_user_name);
 
        THREAD_CREATE(delete_thread, thread_func_to_delete_mail, (void *)thread_func_event_data, thread_error);
-       THREAD_DETACH(delete_thread); /* free resources used for new thread */
+       if (thread_error == 0)
+               THREAD_DETACH(delete_thread); /* free resources used for new thread */
        ret = true;
 
 FINISH_OFF2:
@@ -1090,7 +1091,8 @@ FINISH_OFF:
        thread_func_event_data->multi_user_name = g_strdup(multi_user_name);
 
        THREAD_CREATE(move_thread, thread_func_to_move_mail, (void*)thread_func_event_data, thread_error);
-       THREAD_DETACH(move_thread); /* free resources used for new thread */
+       if (thread_error == 0)
+               THREAD_DETACH(move_thread); /* free resources used for new thread */
        EM_DEBUG_LOG("thread_error [%d]", thread_error);
        ret = true;
 
@@ -1267,7 +1269,8 @@ FINISH_OFF:
        thread_func_event_data->multi_user_name = g_strdup(multi_user_name);
 
        THREAD_CREATE(move_thread, thread_func_to_move_mail, (void*)thread_func_event_data, thread_error);
-       THREAD_DETACH(move_thread); /* free resources used for new thread */
+       if (thread_error == 0)
+               THREAD_DETACH(move_thread); /* free resources used for new thread */
        EM_DEBUG_LOG("thread_error [%d]", thread_error);
        ret = true;