Fix svace issue 35/61635/4 accepted/tizen/common/20160315.221104 accepted/tizen/ivi/20160310.063011 accepted/tizen/ivi/20160315.002148 accepted/tizen/mobile/20160310.062837 accepted/tizen/mobile/20160315.002055 accepted/tizen/tv/20160310.062906 accepted/tizen/tv/20160315.002113 accepted/tizen/wearable/20160310.062940 accepted/tizen/wearable/20160315.002130 submit/tizen/20160310.030656 submit/tizen/20160314.051739
authorJi Yong Min <jiyong.min@samsung.com>
Wed, 9 Mar 2016 08:54:58 +0000 (17:54 +0900)
committerJi Yong Min <jiyong.min@samsung.com>
Wed, 9 Mar 2016 09:17:34 +0000 (18:17 +0900)
Change-Id: I4aefb98d9c317dcf51e893d9e2d6b9314573ed2d
Signed-off-by: Jiyong Min <jiyong.min@samsung.com>
gif/mm_util_gif.c
imgp/test/mm_util_imgp_testsuite.c

index 075f19839b12e656d63258298725df12089e8b58..42f6db33c44e643387d1be3523554945b6fdf6de 100755 (executable)
@@ -327,6 +327,11 @@ static int __save_buffer_to_gif(GifFileType *GifFile, GifByteType *OutputBuffer,
 
        mm_util_debug("__save_buffer_to_gif");
 
+       if (GifFile == NULL) {
+               mm_util_error("Invalid parameter: GifFileType");
+               return MM_UTIL_ERROR_INVALID_PARAMETER;
+       }
+
        /* Find closest color in first color map for the transparent color. */
        color = OutputColorMap->Colors;
        for (z = 0; z < OutputColorMap->ColorCount; z++) {
@@ -357,8 +362,7 @@ static int __save_buffer_to_gif(GifFileType *GifFile, GifByteType *OutputBuffer,
 
        if (EGifPutImageDesc(GifFile, frame->x, frame->y, frame->width, frame->height, false, OutputColorMap) == GIF_ERROR) {
                mm_util_error("could not put image description");
-               if (GifFile != NULL)
-                       EGifCloseFile(GifFile, NULL);
+               EGifCloseFile(GifFile, NULL);
                return MM_UTIL_ERROR_INVALID_OPERATION;
        }
 
@@ -438,11 +442,15 @@ static int __write_gif(mm_util_gif_data *encoded)
        GifByteType *red = NULL, *green = NULL, *blue = NULL, *OutputBuffer = NULL;
        ColorMapObject *OutputColorMap = NULL;
 
+       if (encoded->GifFile == NULL) {
+               mm_util_error("Invalid parameter");
+               return MM_UTIL_ERROR_INVALID_PARAMETER;
+       }
+
        if (!encoded->screen_desc_updated) {
                if (EGifPutScreenDesc(encoded->GifFile, encoded->frames[0]->width, encoded->frames[0]->height, 8, 0, NULL) == GIF_ERROR) {
                        mm_util_error("could not put screen description");
-                       if (encoded->GifFile != NULL)
-                               EGifCloseFile(encoded->GifFile, NULL);
+                       EGifCloseFile(encoded->GifFile, NULL);
                        return MM_UTIL_ERROR_INVALID_OPERATION;
                }
                encoded->screen_desc_updated = true;
index ec69dd2f247bfc29a08a93ca20581abad4d1b777..541caf8e8a416622a84b095bc37ed5f5c5627b6e 100755 (executable)
@@ -159,16 +159,17 @@ int main(int argc, char *argv[])
        uint64_t src_size = 0;
        uint64_t dst_size = 0;
        bool sync_mode = (strcmp(argv[1], "sync") == 0) ? TRUE : FALSE;
-       char *command = NULL;
-       unsigned int src_width = atoi(argv[4]);
-       unsigned int src_height = atoi(argv[5]);
+       char *filename = strdup(argv[2]);
+       char *command = strdup(argv[3]);
+       unsigned int src_width = (unsigned int)atoi(argv[4]);
+       unsigned int src_height = (unsigned int)atoi(argv[5]);
        mm_util_img_format src_format = atoi(argv[6]);
-       unsigned int dst_width = atoi(argv[7]);
-       unsigned int dst_height = atoi(argv[8]);
+       unsigned int dst_width = (unsigned int)atoi(argv[7]);
+       unsigned int dst_height = (unsigned int)atoi(argv[8]);
        mm_util_img_format dst_format = atoi(argv[9]);
        mm_util_img_rotate_type rotation = atoi(argv[10]);
-       mm_util_img_rotate_type start_x = atoi(argv[11]);
-       mm_util_img_rotate_type start_y = atoi(argv[12]);
+       unsigned int start_x = (unsigned int)atoi(argv[11]);
+       unsigned int start_y = (unsigned int)atoi(argv[12]);
        char output_file[40] = {};
 
        /* async mode */
@@ -178,10 +179,6 @@ int main(int argc, char *argv[])
 
        unsigned int size = 0;
 
-       command = (char *)malloc(MAX_STRING_LEN);
-       memset(command, 0x00, MAX_STRING_LEN);
-       snprintf(command, MAX_STRING_LEN, "%s", argv[3]);
-
        mm_util_debug("command: %s src_width: %d, src_height: %d, src_format: %d, dst_width: %d, dst_height: %d, dst_format:%d, rotation:%d", command, src_width, src_height, src_format, dst_width, dst_height, dst_format, rotation);
 
        /* mem allocation for src dst buffer */
@@ -193,7 +190,7 @@ int main(int argc, char *argv[])
        dst = malloc(dst_size);
 
        { /* read input file */
-               FILE *fp = fopen(argv[2], "r");
+               FILE *fp = fopen(filename, "r");
                if (fp == NULL) {
                        mm_util_debug("\tfile open failed %d\n", errno);
                        goto TEST_FAIL;
@@ -404,6 +401,7 @@ TEST_FAIL:
        IMGP_FREE(src);
        IMGP_FREE(dst);
        IMGP_FREE(command);
+       IMGP_FREE(filename);
        if (!sync_mode) {
                media_format_unref(fmt);
                mm_util_debug("Destory - src packet");