[SATIZENVUL-952] Add to check that memory was allocated successfully. 12/138612/3
authorJiyong Min <jiyong.min@samsung.com>
Thu, 13 Jul 2017 03:53:20 +0000 (12:53 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Thu, 13 Jul 2017 03:59:50 +0000 (12:59 +0900)
Change-Id: I51308a8a1fc980a778cbb5a486548cde17521e7f
Signed-off-by: Jiyong Min <jiyong.min@samsung.com>
bmp/mm_util_bmp.c
gif/mm_util_gif.c
packaging/libmm-utility.spec

index 174c6fb..77997d6 100755 (executable)
@@ -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:
index 1e12999..635727d 100755 (executable)
@@ -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;
 }
index 3555305..8071b7d 100755 (executable)
@@ -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