Svace issue fix 96/54996/1
authorHaejeong Kim <backto.kim@samsung.com>
Mon, 21 Dec 2015 07:57:29 +0000 (16:57 +0900)
committerHaejeong Kim <backto.kim@samsung.com>
Mon, 21 Dec 2015 07:57:29 +0000 (16:57 +0900)
Change-Id: Idf60cd77f57ce8afc34fb91e7593ca3b686f33cd

src/common/media-svc-util.c

index a134c58..52f8a79 100755 (executable)
@@ -635,6 +635,15 @@ static int __media_svc_resize_artwork(void *image, int size, const char *img_for
                image_util_calculate_buffer_size(resized_width, resized_height, IMAGE_UTIL_COLORSPACE_RGB888 , &buf_size);
 
                resized_raw_image = malloc(buf_size);
+
+               if (resized_raw_image == NULL) {
+                       media_svc_error("malloc failed");
+                       *resize_image = image;
+                       *resize_size = size;
+                       SAFE_FREE(raw_image);
+                       return MS_MEDIA_ERR_NONE;
+               }
+
                memset(resized_raw_image, 0, buf_size);
 
                ret = image_util_resize(resized_raw_image, &resized_width, &resized_height, raw_image, width, height, IMAGE_UTIL_COLORSPACE_RGB888);
@@ -643,6 +652,7 @@ static int __media_svc_resize_artwork(void *image, int size, const char *img_for
                        *resize_image = image;
                        *resize_size = size;
                        SAFE_FREE(raw_image);
+                       SAFE_FREE(resized_raw_image);
                        return MS_MEDIA_ERR_NONE;
                }
                SAFE_FREE(raw_image);
@@ -653,8 +663,8 @@ static int __media_svc_resize_artwork(void *image, int size, const char *img_for
                        media_svc_error("image_util_encode_jpeg_to_memory failed");
                        *resize_image = image;
                        *resize_size = size;
-                       return MS_MEDIA_ERR_NONE;
                        SAFE_FREE(resized_raw_image);
+                       return MS_MEDIA_ERR_NONE;
                }
                SAFE_FREE(resized_raw_image);