Change free to SAFE_FREE 07/147907/1 accepted/tizen/unified/20170907.060419 submit/tizen/20170906.051057
authorHaejeong Kim <backto.kim@samsung.com>
Wed, 6 Sep 2017 04:46:41 +0000 (13:46 +0900)
committerHaejeong Kim <backto.kim@samsung.com>
Wed, 6 Sep 2017 04:46:41 +0000 (13:46 +0900)
Change-Id: I09f419176a7a3fed9fcb9ff35faee3f9104fb545

bmp/mm_util_bmp.c
gif/mm_util_gif.c
imgcv/mm_util_imgcv.c

index cd9d9a8..9d7a628 100755 (executable)
@@ -76,7 +76,7 @@ static unsigned char *__load_file(const char *path, size_t * data_size)
        n = fread(buffer, 1, size, fd);
        if (n != size) {
                mm_util_error("file read failed");
-               free(buffer);
+               BMP_SAFE_FREE(buffer);
                fclose(fd);
                return NULL;
        }
@@ -121,7 +121,7 @@ size_t __bitmap_get_bpp(void *bitmap)
 
 void __bitmap_destroy(void *bitmap)
 {
-       free(bitmap);
+       BMP_SAFE_FREE(bitmap);
 }
 
 static int __read_bmp(mm_util_bmp_data *decoded, const char *filename, void *memory, unsigned long long src_size)
@@ -184,7 +184,7 @@ static int __read_bmp(mm_util_bmp_data *decoded, const char *filename, void *mem
  cleanup:
        bmp_finalise(&bmp);
        if (filename)
-               free(data);
+               BMP_SAFE_FREE(data);
        return res;
 }
 
index c119f30..a25c529 100755 (executable)
@@ -473,14 +473,14 @@ static int __write_gif(mm_util_gif_data *encoded)
                if ((OutputColorMap = GifMakeMapObject(ColorMapSize, NULL)) == NULL) {
                        mm_util_error("could not map object");
                        RGB_FREE(red, green, blue);
-                       free(OutputBuffer);
+                       MMUTIL_SAFE_FREE(OutputBuffer);
                        mm_util_encode_close_gif(encoded);
                        return MM_UTIL_ERROR_INVALID_OPERATION;
                }
                if (GifQuantizeBuffer(encoded->frames[i]->width, encoded->frames[i]->height, &ColorMapSize, red, green, blue, OutputBuffer, OutputColorMap->Colors) == GIF_ERROR) {
                        mm_util_error("could not quantize buffer");
                        RGB_FREE(red, green, blue);
-                       free(OutputBuffer);
+                       MMUTIL_SAFE_FREE(OutputBuffer);
                        GifFreeMapObject(OutputColorMap);
                        mm_util_encode_close_gif(encoded);
                        return MM_UTIL_ERROR_INVALID_OPERATION;
@@ -502,13 +502,13 @@ static int __write_gif(mm_util_gif_data *encoded)
                /* encode OutputBuffer to GifFile */
                if (__save_buffer_to_gif(encoded->GifFile, OutputBuffer, OutputColorMap, encoded->frames[i]) != MM_UTIL_ERROR_NONE) {
                        mm_util_error("save_buffer_to_gif is failed");
-                       free(OutputBuffer);
+                       MMUTIL_SAFE_FREE(OutputBuffer);
                        GifFreeMapObject(OutputColorMap);
                        mm_util_encode_close_gif(encoded);
                        return MM_UTIL_ERROR_INVALID_OPERATION;
                }
 
-               free(OutputBuffer);
+               MMUTIL_SAFE_FREE(OutputBuffer);
                GifFreeMapObject(OutputColorMap);
                encoded->current_count++;
        }
@@ -600,10 +600,9 @@ int __gif_make_color_map(gif_image_s *gif_image)
        goto SUCCESS;
 
 FAIL:
-       if (gif_image->intermediate_image) {
-               free(gif_image->intermediate_image);
-               gif_image->intermediate_image = NULL;
-       }
+       if (gif_image->intermediate_image)
+               MMUTIL_SAFE_FREE(gif_image->intermediate_image);
+
        gif_image->intermediate_image_size = 0;
        COLORMAP_FREE(gif_image->image_desc.ColorMap);
 SUCCESS:
index de8581a..8a37702 100755 (executable)
@@ -230,8 +230,7 @@ int mm_util_cv_extract_representative_color(void *image_buffer, int width, int h
        int ret = _mm_util_imgcv_init(handle, width, height);
        if (ret != MM_UTIL_ERROR_NONE) {
                _mm_util_imgcv_uninit(handle);
-               free(handle);
-               handle = NULL;
+               MMUTIL_SAFE_FREE(handle);
 
                mm_util_error("#ERROR#: Fail to mm_util_imgcv_init: ret=%d", ret);
 
@@ -241,8 +240,7 @@ int mm_util_cv_extract_representative_color(void *image_buffer, int width, int h
        ret = _mm_util_imgcv_set_buffer(handle, image_buffer);
        if (ret != MM_UTIL_ERROR_NONE) {
                _mm_util_imgcv_uninit(handle);
-               free(handle);
-               handle = NULL;
+               MMUTIL_SAFE_FREE(handle);
 
                mm_util_error("#ERROR#: Fail to mm_util_imgcv_set_buffer: ret=%d", ret);
 
@@ -252,8 +250,7 @@ int mm_util_cv_extract_representative_color(void *image_buffer, int width, int h
        ret = _mm_util_imgcv_calculate_hist(handle, r_color, g_color, b_color);
        if (ret != MM_UTIL_ERROR_NONE) {
                _mm_util_imgcv_uninit(handle);
-               free(handle);
-               handle = NULL;
+               MMUTIL_SAFE_FREE(handle);
 
                mm_util_error("#ERROR#: Fail to mm_util_imgcv_calculate_hist: ret=%d", ret);
 
@@ -262,8 +259,7 @@ int mm_util_cv_extract_representative_color(void *image_buffer, int width, int h
 
        _mm_util_imgcv_uninit(handle);
 
-       free(handle);
-       handle = NULL;
+       MMUTIL_SAFE_FREE(handle);
 
        mm_util_debug("Leave mm_util_cv_extract_representative_color");