summaryrefslogtreecommitdiff
path: root/libavformat/mux.c
diff options
context:
space:
mode:
authorNidhi Makhijani <nidhimj22@gmail.com>2014-07-14 11:52:44 +0530
committerDiego Biurrun <diego@biurrun.de>2014-07-17 03:18:46 -0700
commit324ff59444ff5470bb325ff1e2be7c4b054fc944 (patch)
tree787e31d54ea7f2b4f94e3aec84afbb62bb98c9e0 /libavformat/mux.c
parent2db953f84671997e936f91140ffb5143c1537844 (diff)
avpacket: Check for and return errors in ff_interleave_add_packet()
Signed-off-by: Diego Biurrun <diego@biurrun.de>
Diffstat (limited to 'libavformat/mux.c')
-rw-r--r--libavformat/mux.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 9c2144acc1..df4f57a7f3 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -384,12 +384,15 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt)
return ret;
}
-void ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
- int (*compare)(AVFormatContext *, AVPacket *, AVPacket *))
+int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
+ int (*compare)(AVFormatContext *, AVPacket *, AVPacket *))
{
+ int ret;
AVPacketList **next_point, *this_pktl;
this_pktl = av_mallocz(sizeof(AVPacketList));
+ if (!this_pktl)
+ return AVERROR(ENOMEM);
this_pktl->pkt = *pkt;
#if FF_API_DESTRUCT_PACKET
FF_DISABLE_DEPRECATION_WARNINGS
@@ -397,7 +400,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-alloced 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;
+ }
if (s->streams[pkt->stream_index]->last_in_packet_buffer) {
next_point = &(s->streams[pkt->stream_index]->last_in_packet_buffer->next);
@@ -422,6 +429,8 @@ next_non_null:
s->streams[pkt->stream_index]->last_in_packet_buffer =
*next_point = this_pktl;
+
+ return 0;
}
static int interleave_compare_dts(AVFormatContext *s, AVPacket *next,
@@ -442,10 +451,11 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
{
AVPacketList *pktl;
int stream_count = 0;
- int i;
+ int i, ret;
if (pkt) {
- ff_interleave_add_packet(s, pkt, interleave_compare_dts);
+ if ((ret = ff_interleave_add_packet(s, pkt, interleave_compare_dts)) < 0)
+ return ret;
}
if (s->max_interleave_delta > 0 && s->packet_buffer && !flush) {