Fix confusing error logging 43/155843/1
authorAnastasia Lyupa <a.lyupa@samsung.com>
Mon, 16 Oct 2017 09:08:38 +0000 (12:08 +0300)
committerAnastasia Lyupa <a.lyupa@samsung.com>
Mon, 16 Oct 2017 09:19:01 +0000 (12:19 +0300)
Fix _image_util_decode_create_*_handle().
Check image_handle before trying to reallocate it.
Otherwise meaningless error are recorded.

Change-Id: I981176a447099c9ed1f5b8d18c5163a48c561c08
Signed-off-by: Anastasia Lyupa <a.lyupa@samsung.com>
src/image_util_decode.c

index 3712b5e6b38bd23e1dd367ff63a404e453fecc5d..c9e8715a7734f9872736a75a7a347309c18fbd48 100755 (executable)
@@ -120,7 +120,9 @@ static int _image_util_decode_create_jpeg_handle(decode_encode_s * handle)
        image_util_retvm_if((handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
 
        /* It is needed to reuse decode handle for C#, so it shoud be reallocated */
-       _image_util_decode_destroy_image_handle(handle);
+       void *image_handle =  (void *)(handle->image_h);
+       if (image_handle != NULL)
+               _image_util_decode_destroy_image_handle(handle);
 
        mm_util_jpeg_yuv_data *_handle = (mm_util_jpeg_yuv_data *) calloc(1, sizeof(mm_util_jpeg_yuv_data));
        image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
@@ -137,7 +139,9 @@ static int _image_util_decode_create_png_handle(decode_encode_s * handle)
        image_util_retvm_if((handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
 
        /* It is needed to reuse decode handle for C#, so it shoud be reallocated */
-       _image_util_decode_destroy_image_handle(handle);
+       void *image_handle =  (void *)(handle->image_h);
+       if (image_handle != NULL)
+               _image_util_decode_destroy_image_handle(handle);
 
        mm_util_png_data *_handle = (mm_util_png_data *) calloc(1, sizeof(mm_util_png_data));
        image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
@@ -154,7 +158,9 @@ static int _image_util_decode_create_gif_handle(decode_encode_s * handle)
        image_util_retvm_if((handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
 
        /* It is needed to reuse decode handle for C#, so it shoud be reallocated */
-       _image_util_decode_destroy_image_handle(handle);
+       void *image_handle =  (void *)(handle->image_h);
+       if (image_handle != NULL)
+               _image_util_decode_destroy_image_handle(handle);
 
        mm_util_gif_data *_handle = (mm_util_gif_data *) calloc(1, sizeof(mm_util_gif_data));
        image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
@@ -169,7 +175,9 @@ static int _image_util_decode_create_bmp_handle(decode_encode_s * handle)
        image_util_retvm_if((handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
 
        /* It is needed to reuse decode handle for C#, so it shoud be reallocated */
-       _image_util_decode_destroy_image_handle(handle);
+       void *image_handle =  (void *)(handle->image_h);
+       if (image_handle != NULL)
+               _image_util_decode_destroy_image_handle(handle);
 
        mm_util_bmp_data *_handle = (mm_util_bmp_data *) calloc(1, sizeof(mm_util_bmp_data));
        image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");