From: Jiyong Min Date: Thu, 13 Jul 2017 03:53:20 +0000 (+0900) Subject: [SATIZENVUL-952] Add to check that memory was allocated successfully. X-Git-Tag: submit/tizen/20170719.012528~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e5d0ec0194c82d681f0846babf48c6e4009f151f;p=platform%2Fcore%2Fmultimedia%2Flibmm-utility.git [SATIZENVUL-952] Add to check that memory was allocated successfully. Change-Id: I51308a8a1fc980a778cbb5a486548cde17521e7f Signed-off-by: Jiyong Min --- diff --git a/bmp/mm_util_bmp.c b/bmp/mm_util_bmp.c index 174c6fb..77997d6 100755 --- a/bmp/mm_util_bmp.c +++ b/bmp/mm_util_bmp.c @@ -174,6 +174,11 @@ static int __read_bmp(mm_util_bmp_data *decoded, const char *filename, void *mem decoded->height = bmp.height; decoded->size = bmp.width * bmp.height * BYTES_PER_PIXEL; decoded->data = malloc(decoded->size); + if (decoded->data == NULL) { + mm_util_error("Failed to saved memory allocation"); + res = MM_UTIL_ERROR_OUT_OF_MEMORY; + goto cleanup; + } memcpy(decoded->data, bmp.bitmap, decoded->size); cleanup: diff --git a/gif/mm_util_gif.c b/gif/mm_util_gif.c index 1e12999..635727d 100755 --- a/gif/mm_util_gif.c +++ b/gif/mm_util_gif.c @@ -392,8 +392,10 @@ static int __write_function(GifFileType *gft, const GifByteType *data, int size) if (size > 0) { *(write_data_ptr->mem) = (void *)realloc(*(write_data_ptr->mem), (write_data_ptr->size + size)); - memcpy(*(write_data_ptr->mem) + write_data_ptr->size, data, size); - write_data_ptr->size += size; + if (*(write_data_ptr->mem) != NULL) { + memcpy(*(write_data_ptr->mem) + write_data_ptr->size, data, size); + write_data_ptr->size += size; + } } return size; } diff --git a/packaging/libmm-utility.spec b/packaging/libmm-utility.spec index 3555305..8071b7d 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.31 +Version: 0.32 Release: 0 Group: System/Libraries License: Apache-2.0