PVS-studio error fix 74/132874/2 accepted/tizen/unified/20170608.072600 submit/tizen/20170608.060041
authorHaejeong Kim <backto.kim@samsung.com>
Thu, 8 Jun 2017 05:25:06 +0000 (14:25 +0900)
committerhj kim <backto.kim@samsung.com>
Thu, 8 Jun 2017 05:25:59 +0000 (05:25 +0000)
(https://www.slideshare.net/Andrey_Karpov/pvsstudio-is-ready-to-improve-the-code-of-tizen-operating-system)
Change-Id: Idbbdb425e183dfafc8728d96018f35972c821a3d

packaging/capi-content-media-content.spec
test/media-content_test.c

index b36928b..0c6d02b 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-content-media-content
 Summary:    A Media content library in Tizen Native API
-Version:    0.3.12
+Version:    0.3.13
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index c8493cb..f219a27 100755 (executable)
@@ -3070,7 +3070,7 @@ void insert_batch_cb(media_content_error_e error, void * user_data)
 int test_batch_operations()
 {
        int ret = -1;
-       int i;
+       int i = 0;
        char *file_list[10];
 
        for (i = 0; i < 10; i++) {
@@ -3085,8 +3085,13 @@ int test_batch_operations()
                media_content_error("media_info_insert_batch_to_db failed : %d\n", ret);
 
        filter_h filter;
-       char *condition = "MEDIA_PATH LIKE \'";
-       strncat(condition, tzplatform_mkpath(TZ_USER_CONTENT, "test/image%%jpg\'"), 17);
+       char condition[2048] = {0, };
+       const char *temp = NULL;
+       memset(condition, 0x00, sizeof(condition));
+
+       temp = tzplatform_mkpath(TZ_USER_CONTENT, "test/image%%jpg\'");
+       snprintf(condition, sizeof(condition), "MEDIA_PATH LIKE \'%s", temp);
+
        ret = media_filter_create(&filter);
        if (ret != MEDIA_CONTENT_ERROR_NONE) {
                media_content_error("Fail to create filter");
@@ -3336,6 +3341,8 @@ gboolean _send_noti_operations(gpointer data)
        filter_h filter;
        char condition[2048] = {0,};
        const char *temp = NULL;
+       memset(condition, 0x00, sizeof(condition));
+
        temp = tzplatform_mkpath(TZ_USER_CONTENT, "test/image%%\'");
        snprintf(condition, sizeof(condition), "MEDIA_PATH LIKE \'%s", temp);