Fix Memory leak 36/157336/2 accepted/tizen/unified/20171025.075231 submit/tizen/20171024.235653
authorhj kim <backto.kim@samsung.com>
Tue, 24 Oct 2017 07:53:00 +0000 (16:53 +0900)
committerhj kim <backto.kim@samsung.com>
Tue, 24 Oct 2017 11:07:01 +0000 (20:07 +0900)
Change-Id: I53f4585b12708aeeb7b41452f4b79ddfdbebed81

formats/ffmpeg/mm_file_format_ffmpeg.c
formats/ffmpeg/mm_file_format_frame.c
packaging/libmm-fileinfo.spec

index 4bf8001..4b57870 100755 (executable)
@@ -875,7 +875,7 @@ int mmfile_format_read_frame_ffmpg(MMFileFormatContext *formatContext, unsigned
                frame->configLenth = 0;
                frame->bCompressed = 0; /* false */
 
-               if (pFrame)                     av_free(pFrame);
+               if (pFrame)                     av_frame_free(&pFrame);
 
                avcodec_free_context(&pVideoCodecCtx);
 
@@ -890,7 +890,7 @@ exception:
                mmfile_free(frame->frameData);
                frame->frameData = NULL;
        }
-       if (pFrame)             av_free(pFrame);
+       if (pFrame)             av_frame_free(&pFrame);
 
        return ret;
 }
@@ -1089,8 +1089,8 @@ static int _get_first_good_video_frame(AVFormatContext *pFormatCtx, AVCodecConte
 
        if (!first_frame || !tmp_frame) {
                debug_error(DEBUG, "failed to alloc frame.\n");
-               if (first_frame) av_free(first_frame);
-               if (tmp_frame) av_free(tmp_frame);
+               if (first_frame) av_frame_free(&first_frame);
+               if (tmp_frame) av_frame_free(&tmp_frame);
                return MMFILE_FORMAT_FAIL;
        }
 
@@ -1190,7 +1190,7 @@ static int _get_first_good_video_frame(AVFormatContext *pFormatCtx, AVCodecConte
        }
 
        /*free pkt after loop breaking*/
-       if (pkt.data) av_packet_unref(&pkt);
+       av_packet_unref(&pkt);
 
        debug_msg(RELEASE, "found: %d, retry: %d\n", found, retry);
 
@@ -1199,15 +1199,15 @@ static int _get_first_good_video_frame(AVFormatContext *pFormatCtx, AVCodecConte
                ret = MMFILE_FORMAT_SUCCESS;
                if (retry == 0 || found == retry) {
                        *pFrame = first_frame;
-                       if (tmp_frame) av_free(tmp_frame);
+                       if (tmp_frame) av_frame_free(&tmp_frame);
                } else {
                        *pFrame = tmp_frame;
-                       if (first_frame) av_free(first_frame);
+                       if (first_frame) av_frame_free(&first_frame);
                }
        } else {
                ret = MMFILE_FORMAT_FAIL;
-               if (first_frame) av_free(first_frame);
-               if (tmp_frame) av_free(tmp_frame);
+               if (first_frame) av_frame_free(&first_frame);
+               if (tmp_frame) av_frame_free(&tmp_frame);
        }
 
        debug_msg(RELEASE, "out frame: %p\n", *pFrame);
index 46c0346..5aa3dad 100755 (executable)
@@ -637,7 +637,7 @@ static int __mmfile_get_frame(AVFormatContext *pFormatCtx, int64_t timestamp, bo
                goto exception;
        }
 
-       if (pFrame)                     av_free(pFrame);
+       if (pFrame)                     av_frame_free(&pFrame);
        if (pVideoCodecCtx)     avcodec_free_context(&pVideoCodecCtx);
 
        return MMFILE_FORMAT_SUCCESS;
@@ -647,7 +647,7 @@ exception:
                mmfile_free(*frame);
                *frame = NULL;
        }
-       if (pFrame)                     av_free(pFrame);
+       if (pFrame)                     av_frame_free(&pFrame);
        if (pVideoCodecCtx)     avcodec_free_context(&pVideoCodecCtx);
 
        return ret;
index 8d2b109..be813f9 100755 (executable)
@@ -1,6 +1,6 @@
 Name:      libmm-fileinfo
 Summary:    Media Fileinfo
-Version:    0.6.70
+Version:    0.6.71
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0