Fix leak and double-free in gif encoding 78/157778/1
authorAnastasia Lyupa <a.lyupa@samsung.com>
Thu, 26 Oct 2017 07:35:12 +0000 (10:35 +0300)
committerAnastasia Lyupa <a.lyupa@samsung.com>
Thu, 26 Oct 2017 07:35:12 +0000 (10:35 +0300)
Not return before free remaining data in mm_util_gif_encode_destroy().
Free gif_file->saved_image after all saved images are freed
in mm_util_gif_encode().

Change-Id: I318049461669d769f6126c395089c56ab2311bc0
Signed-off-by: Anastasia Lyupa <a.lyupa@samsung.com>
gif/mm_util_gif.c

index d6f3ddc75545168bb8081a3b1b75ccfa6c482f27..4cf2c57dd17b7fa8cf4b3f9d1731db206c05e540 100755 (executable)
@@ -1353,7 +1353,6 @@ int mm_util_gif_encode_save(mm_gif_file_h gif_file_h)
        return MM_UTIL_ERROR_NONE;
 }
 
-
 int mm_util_gif_enocde_set_image_handle(mm_gif_file_h gif_file_h, mm_gif_image_h gif_image_h)
 {
        gif_file_s *gif_file = (gif_file_s *)gif_file_h;
@@ -1417,6 +1416,7 @@ int mm_util_gif_encode(mm_gif_file_h gif_file_h)
                mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "mm_util_gif_encode_add_image failed");
                mm_util_gif_image_destory(gif_image);
        }
+       MMUTIL_SAFE_FREE(gif_file->saved_image);
 
        ret = mm_util_gif_encode_save(gif_file_h);
        mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "mm_util_gif_encode_save failed");
@@ -1431,7 +1431,6 @@ void mm_util_gif_encode_destroy(mm_gif_file_h gif_file_h)
        gif_file_s *gif_file = (gif_file_s *)gif_file_h;
 
        mm_util_retm_if(gif_file == NULL, "Invalid parameter");
-       mm_util_retm_if(gif_file->GifFile == NULL, "GifFile has already closed");
 
        if (gif_file->GifFile != NULL) {
                ret = _gif_encode_close_file(gif_file);