[FFmpeg-devel] [PATCH 2/2] avformat/nutenc: use av_reallocp_array()

Paul B Mahol onemda at gmail.com
Sat Sep 14 16:28:00 CEST 2013


Fixes memleak on allocation error.

Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libavformat/nutenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index 365b463..f24813b 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -864,7 +864,7 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt)
             for (i=0; i<s->nb_streams; i++) {
                 int j;
                 StreamContext *nus = &nut->stream[i];
-                nus->keyframe_pts = av_realloc(nus->keyframe_pts, 2*nut->sp_count*sizeof(*nus->keyframe_pts));
+                av_reallocp_array(&nus->keyframe_pts, 2*nut->sp_count, sizeof(*nus->keyframe_pts));
                 if (!nus->keyframe_pts)
                     return AVERROR(ENOMEM);
                 for (j=nut->sp_count == 1 ? 0 : nut->sp_count; j<2*nut->sp_count; j++)
-- 
1.7.11.2



More information about the ffmpeg-devel mailing list