Add deinitialize of sqlite3 and rand_r() 20/236420/8 accepted/tizen/unified/20200619.121811 submit/tizen/20200618.140547
authorJinWang An <jinwang.an@samsung.com>
Wed, 17 Jun 2020 12:40:01 +0000 (21:40 +0900)
committerJinWang An <jinwang.an@samsung.com>
Thu, 18 Jun 2020 13:28:16 +0000 (22:28 +0900)
Change-Id: Ifbecefe45d72686adef70f0b019a2d8d3b6e51fc
Signed-off-by: JinWang An <jinwang.an@samsung.com>
tests/mocks/vconf.cpp
tests/sstt_test.c

index ba15569..a8a7cd0 100644 (file)
@@ -360,8 +360,10 @@ static int _vconf_set_str(const char *in_key, const char *strval)
                        _sqlite_close();
                        return VCONF_ERROR;
                }
+               sqlite3_finalize(stmt);
        }
 #endif
+       _sqlite_close();
        return VCONF_OK;
 }
 
@@ -499,9 +501,17 @@ API char *vconf_get_str(const char *in_key)
                        sqlite3_column_text(stmt, 2));
 
        str = (char*)malloc(MAX_BUF_LEN + 1);
+       if (NULL == str) {
+               ERR("malloc(%d) Fail()", MAX_BUF_LEN + 1);
+               sqlite3_finalize(stmt);
+               _sqlite_close();
+               return NULL;
+       }
+
        strncpy(str, (char*)sqlite3_column_text(stmt, 2), MAX_BUF_LEN);
 
        sqlite3_finalize(stmt);
+       _sqlite_close();
 
        DBG("vconf get: key[%s], value[%s]", in_key, str);
        return str;
index be937e9..f0fe221 100644 (file)
@@ -2459,9 +2459,9 @@ RETTYPE utc_system_settings_set_value_int_p2(void)
                SYSTEM_SETTINGS_FONT_SIZE_GIANT
        };
 
-       srand(time(NULL));
+       unsigned int next_val = time(NULL);
        int size = sizeof(arr) / sizeof(arr[0]);
-       int sel = rand() % size;
+       int sel = rand_r(&next_val) % size;
 
        /* backup */
        ret = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &backup);