From 40bacbd70ad53b79ee756438f26d7368ebae9938 Mon Sep 17 00:00:00 2001 From: hj kim Date: Tue, 24 Oct 2017 16:53:00 +0900 Subject: [PATCH] Fix Memory leak Change-Id: I53f4585b12708aeeb7b41452f4b79ddfdbebed81 --- formats/ffmpeg/mm_file_format_ffmpeg.c | 18 +++++++++--------- formats/ffmpeg/mm_file_format_frame.c | 4 ++-- packaging/libmm-fileinfo.spec | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/formats/ffmpeg/mm_file_format_ffmpeg.c b/formats/ffmpeg/mm_file_format_ffmpeg.c index 4bf8001..4b57870 100755 --- a/formats/ffmpeg/mm_file_format_ffmpeg.c +++ b/formats/ffmpeg/mm_file_format_ffmpeg.c @@ -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); diff --git a/formats/ffmpeg/mm_file_format_frame.c b/formats/ffmpeg/mm_file_format_frame.c index 46c0346..5aa3dad 100755 --- a/formats/ffmpeg/mm_file_format_frame.c +++ b/formats/ffmpeg/mm_file_format_frame.c @@ -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; diff --git a/packaging/libmm-fileinfo.spec b/packaging/libmm-fileinfo.spec index 8d2b109..be813f9 100755 --- a/packaging/libmm-fileinfo.spec +++ b/packaging/libmm-fileinfo.spec @@ -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 -- 2.7.4