From: Ji Yong Min Date: Wed, 9 Mar 2016 08:54:58 +0000 (+0900) Subject: Fix svace issue X-Git-Tag: submit/tizen/20160310.030656^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b724ff37f1f1ab73b7a76047b0fc5cf4665b8a30;p=platform%2Fcore%2Fmultimedia%2Flibmm-utility.git Fix svace issue Change-Id: I4aefb98d9c317dcf51e893d9e2d6b9314573ed2d Signed-off-by: Jiyong Min --- diff --git a/gif/mm_util_gif.c b/gif/mm_util_gif.c index 075f198..42f6db3 100755 --- a/gif/mm_util_gif.c +++ b/gif/mm_util_gif.c @@ -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; diff --git a/imgp/test/mm_util_imgp_testsuite.c b/imgp/test/mm_util_imgp_testsuite.c index ec69dd2..541caf8 100755 --- a/imgp/test/mm_util_imgp_testsuite.c +++ b/imgp/test/mm_util_imgp_testsuite.c @@ -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");