From: Jiyong Min Date: Mon, 18 Jul 2016 07:40:00 +0000 (+0900) Subject: Add to free file handler for gif encoder X-Git-Tag: submit/tizen/20160719.013718^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=85bf019a063d105f00bacddd9c1468da9db6e0bf;p=platform%2Fcore%2Fmultimedia%2Flibmm-utility.git Add to free file handler for gif encoder Change-Id: Icd220ee38d64a3eba63c90a4ffc01e54134dcc48 Signed-off-by: Jiyong Min --- diff --git a/gif/mm_util_gif.c b/gif/mm_util_gif.c index 0f4f2a7..3b92a2d 100755 --- a/gif/mm_util_gif.c +++ b/gif/mm_util_gif.c @@ -370,7 +370,6 @@ 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"); - EGifCloseFile(GifFile, NULL); return MM_UTIL_ERROR_INVALID_OPERATION; } @@ -379,8 +378,6 @@ static int __save_buffer_to_gif(GifFileType *GifFile, GifByteType *OutputBuffer, unsigned char c = Ptr[pixels++]; if (EGifPutPixel(GifFile, c) == GIF_ERROR) { mm_util_error("could not put pixel"); - if (GifFile != NULL) - EGifCloseFile(GifFile, NULL); return MM_UTIL_ERROR_INVALID_OPERATION; } } @@ -435,10 +432,15 @@ int mm_util_encode_open_gif_memory(mm_util_gif_data *encoded, void **data) int mm_util_encode_close_gif(mm_util_gif_data *encoded) { mm_util_debug("mm_util_encode_close_gif"); + if (encoded->GifFile == NULL) { + mm_util_error("Invalid parameter"); + return MM_UTIL_ERROR_INVALID_PARAMETER; + } if (EGifCloseFile(encoded->GifFile, NULL) == GIF_ERROR) { mm_util_error("could not close file"); return MM_UTIL_ERROR_INVALID_OPERATION; } + encoded->GifFile = NULL; return MM_UTIL_ERROR_NONE; } @@ -458,7 +460,7 @@ static int __write_gif(mm_util_gif_data *encoded) 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"); - EGifCloseFile(encoded->GifFile, NULL); + mm_util_encode_close_gif(encoded); return MM_UTIL_ERROR_INVALID_OPERATION; } encoded->screen_desc_updated = true; @@ -467,6 +469,7 @@ static int __write_gif(mm_util_gif_data *encoded) for (i = encoded->current_count; i < encoded->image_count; i++) { if ((OutputBuffer = (GifByteType *) malloc(encoded->frames[i]->width * encoded->frames[i]->height * sizeof(GifByteType))) == NULL) { mm_util_error("Failed to allocate memory required, aborted."); + mm_util_encode_close_gif(encoded); return MM_UTIL_ERROR_INVALID_OPERATION; } @@ -479,6 +482,7 @@ static int __write_gif(mm_util_gif_data *encoded) free((char *)green); free((char *)blue); free(OutputBuffer); + mm_util_encode_close_gif(encoded); return MM_UTIL_ERROR_INVALID_OPERATION; } if (GifQuantizeBuffer(encoded->frames[i]->width, encoded->frames[i]->height, &ColorMapSize, red, green, blue, OutputBuffer, OutputColorMap->Colors) == GIF_ERROR) { @@ -487,6 +491,7 @@ static int __write_gif(mm_util_gif_data *encoded) free((char *)green); free((char *)blue); free(OutputBuffer); + mm_util_encode_close_gif(encoded); return MM_UTIL_ERROR_INVALID_OPERATION; } free((char *)red); @@ -508,6 +513,7 @@ static int __write_gif(mm_util_gif_data *encoded) if (__save_buffer_to_gif(encoded->GifFile, OutputBuffer, OutputColorMap, encoded->frames[i]) != MM_UTIL_ERROR_NONE) { mm_util_error("save_buffer_to_gif is failed"); free(OutputBuffer); + mm_util_encode_close_gif(encoded); return MM_UTIL_ERROR_INVALID_OPERATION; } @@ -516,6 +522,7 @@ static int __write_gif(mm_util_gif_data *encoded) } encoded->size = encoded->write_data_ptr.size; + mm_util_encode_close_gif(encoded); return MM_UTIL_ERROR_NONE; } diff --git a/packaging/libmm-utility.spec b/packaging/libmm-utility.spec index 0b78fa0..00789ab 100755 --- a/packaging/libmm-utility.spec +++ b/packaging/libmm-utility.spec @@ -1,6 +1,6 @@ Name: libmm-utility Summary: Multimedia Framework Utility Library -Version: 0.24 +Version: 0.25 Release: 0 Group: System/Libraries License: Apache-2.0