fix svace issues
[platform/core/messaging/email-service.git] / email-core / email-storage / email-storage.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);