PVS-studio error fix 77/132877/1 accepted/tizen/unified/20170608.072547 submit/tizen/20170608.060822
authorJiyong Min <jiyong.min@samsung.com>
Thu, 8 Jun 2017 05:57:03 +0000 (14:57 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Thu, 8 Jun 2017 05:58:07 +0000 (14:58 +0900)
(https://www.slideshare.net/Andrey_Karpov/pvsstudio-is-ready-to-improve-the-code-of-tizen-operating-system)

Change-Id: Ida15c5c2a90042dcc485b4d6da4e456f1c8ca97a
Signed-off-by: Jiyong Min <jiyong.min@samsung.com>
decode-test/image_util_decode_encode_testsuite.c
packaging/capi-media-image-util.spec

index e1da546..d495481 100755 (executable)
@@ -188,9 +188,7 @@ int main(int argc, char *argv[])
                0,};
                unsigned char *animated_data[1000] = {NULL, };
                memset(gif_filename, 0, BUFFER_SIZE);
-               {
-                       snprintf(gif_filename, BUFFER_SIZE, "%s%s", DECODE_RESULT_PATH, "gif");
-               }
+               snprintf(gif_filename, BUFFER_SIZE, "%s%s", DECODE_RESULT_PATH, "gif");
 
                if ((fd = opendir(argv[2])) == NULL) {
                        fprintf(stderr, "listdir: can't open %s\n", argv[2]);
@@ -198,12 +196,20 @@ int main(int argc, char *argv[])
                }
 
                while ((dp = readdir(fd)) != NULL) {
+                       if (dp->d_name == NULL)
+                               continue;
                        if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, ".."))
                                continue;               /* skip self and parent */
                        if (!number_files) {
                                char *temp1 = strstr(dp->d_name, "-");
                                char *temp2 = strstr(dp->d_name, ".");
 
+                               if (temp1 == NULL || temp2 == NULL) {
+                                       fprintf(stderr, "\t\tCannot find test format\n");
+                                       closedir(fd);
+                                       return 0;
+                               }
+
                                strncpy(temp_filename, dp->d_name, strlen(dp->d_name) - strlen(temp1));
                                strncpy(file_format, temp2, strlen(temp2));
                        }
index 9bdf7fe..4fd6fc0 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-image-util
 Summary:    A Image Utility library in Tizen Native API
-Version:    0.1.15
+Version:    0.1.16
 Release:    2
 Group:      Multimedia/API
 License:    Apache-2.0