[FFmpeg-devel] [PATCH] lavf/mux: check av_dup_packet() return value.
Nicolas George
george at nsup.org
Sat Jan 4 17:39:10 CET 2014
Signed-off-by: Nicolas George <george at nsup.org>
---
libavformat/mux.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
Simulating the failure (this_pktl->pkt.size = 2000000000) leaks with
ffmpeg_g, but that is to be expected since it calls exit_program(1)
immediately.
diff --git a/libavformat/mux.c b/libavformat/mux.c
index bd50191..f501abd 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -585,6 +585,7 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
AVPacketList **next_point, *this_pktl;
AVStream *st = s->streams[pkt->stream_index];
int chunked = s->max_chunk_size || s->max_chunk_duration;
+ int ret;
this_pktl = av_mallocz(sizeof(AVPacketList));
if (!this_pktl)
@@ -596,7 +597,11 @@ FF_DISABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
#endif
pkt->buf = NULL;
- av_dup_packet(&this_pktl->pkt); // duplicate the packet if it uses non-allocated memory
+ // duplicate the packet if it uses non-allocated memory
+ if ((ret = av_dup_packet(&this_pktl->pkt)) < 0) {
+ av_free(this_pktl);
+ return ret;
+ }
av_copy_packet_side_data(&this_pktl->pkt, &this_pktl->pkt); // copy side data
if (s->streams[pkt->stream_index]->last_in_packet_buffer) {
--
1.7.10.4
More information about the ffmpeg-devel
mailing list