[FFmpeg-devel] Memory leaks in libavformat/segment.c

Lvqier lvqier at gmail.com
Tue Dec 8 11:19:33 CET 2015


Hi Hendrik,

     The attached is another patch which uses av_reallocp to fix this issue.

/Best Regards,
lvqier - lvqier at gmail.com <mailto:lvqier at gmail.com>
/

******************************************
青春如烟,唱一首笑忘歌

On 12/5/15 11:23 PM, Lvqier wrote:
> Ok, I will try av_reallocp
>
> /Best Regards,
> lvqier - lvqier at gmail.com <mailto:lvqier at gmail.com>
> /
> ******************************************
> 青春如烟,唱一首笑忘歌
> On 12/5/15 7:27 PM, Hendrik Leppkes wrote:
>> On Sat, Dec 5, 2015 at 11:02 AM, Qier LU<lvqier at gmail.com>  wrote:
>>> Hi Michael,
>>>
>>> The attached is against git master.
>>>
>> The patch is probably fine now. Maybe it would be saner to actually
>> use av_reallocp on the filename to avoid having to allocate and free
>> it in different places?
>>
>> - Hendrik
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

-------------- next part --------------
diff --git a/libavformat/segment.c b/libavformat/segment.c
index 8432d0f..f230251 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -206,8 +206,7 @@ static int set_segment_filename(AVFormatContext *s)
     if (seg->entry_prefix)
         size += strlen(seg->entry_prefix);
 
-    seg->cur_entry.filename = av_mallocz(size);
-    if (!seg->cur_entry.filename)
+    if (av_reallocp(&seg->cur_entry.filename, size))
         return AVERROR(ENOMEM);
     snprintf(seg->cur_entry.filename, size, "%s%s",
              seg->entry_prefix ? seg->entry_prefix : "",


More information about the ffmpeg-devel mailing list