Fix issues 31/74131/1 accepted/tizen/common/20160614.143823 accepted/tizen/ivi/20160614.042623 accepted/tizen/mobile/20160614.041621 accepted/tizen/tv/20160614.041613 accepted/tizen/wearable/20160614.042139 submit/tizen/20160614.004549
authorJunghyun Yeon <jungh.yeon@samsung.com>
Mon, 13 Jun 2016 02:48:08 +0000 (11:48 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Mon, 13 Jun 2016 02:48:08 +0000 (11:48 +0900)
- replace strtok into strtok_r for thread-safe
- supress build warning

Change-Id: I1b4f390fa0ec5e0d4c9cf69c1c47e251f0aec357
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/pkgmgrinfo_certinfo.c
src/pkgmgrinfo_private.c

index 1f1a533..5a25a22 100644 (file)
@@ -106,9 +106,7 @@ static int _pkginfo_compare_certinfo(sqlite3 *db, const char *l_pkgid,
        else
                *result = PMINFO_CERT_COMPARE_MISMATCH;
 
-catch:
        sqlite3_finalize(stmt);
-
        return PMINFO_R_OK;
 }
 
index 8312354..bc7d97c 100644 (file)
@@ -238,6 +238,7 @@ int __get_filter_condition(gpointer data, char **condition, GList **params)
        char buf[MAX_QUERY_LEN] = {'\0'};
        int flag = 0;
        char *ptr = NULL;
+       char *saveptr = NULL;
 
        switch (node->prop) {
        case E_PMINFO_PKGINFO_PROP_PACKAGE_ID:
@@ -326,10 +327,12 @@ int __get_filter_condition(gpointer data, char **condition, GList **params)
                break;
        case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
                snprintf(buf, sizeof(buf), "package_app_app_category.category IN (");
-               ptr = strtok(node->value, ",");
+               ptr = strtok_r(node->value, ",", &saveptr);
+               if (ptr == NULL)
+                       return 0;
                strncat(buf, "?", MAX_QUERY_LEN - 2);
                *params = g_list_append(*params, strdup(ptr));
-               while ((ptr = strtok(NULL, ","))) {
+               while ((ptr = strtok_r(NULL, ",", &saveptr))) {
                        strncat(buf, ", ?", MAX_QUERY_LEN - strlen(", ?") - 1);
                        *params = g_list_append(*params, strdup(ptr));
                }