aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2015-09-16 12:07:00 +0200
committerLuca Barbato <lu_zero@gentoo.org>2015-09-16 20:20:16 +0200
commit22cc57da64bfd73f2206969486b0aa183ee76479 (patch)
tree01efcd7112a7b8fc619d83bd0ebfa9e11d5a6d96
parent1ec611a10228945d2ec8a9cf6c5531dee6b7ee56 (diff)
downloadffmpeg-22cc57da64bfd73f2206969486b0aa183ee76479.tar.gz
rtpdec: Forward the memory failure
And avoid a memory leak. Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
-rw-r--r--libavformat/rtpdec.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 34c77f8819..823e03cf52 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -684,7 +684,7 @@ void ff_rtp_reset_packet_queue(RTPDemuxContext *s)
s->prev_ret = 0;
}
-static void enqueue_packet(RTPDemuxContext *s, uint8_t *buf, int len)
+static int enqueue_packet(RTPDemuxContext *s, uint8_t *buf, int len)
{
uint16_t seq = AV_RB16(buf + 2);
RTPPacket **cur = &s->queue, *packet;
@@ -699,7 +699,7 @@ static void enqueue_packet(RTPDemuxContext *s, uint8_t *buf, int len)
packet = av_mallocz(sizeof(*packet));
if (!packet)
- return;
+ return AVERROR(ENOMEM);
packet->recvtime = av_gettime_relative();
packet->seq = seq;
packet->len = len;
@@ -707,6 +707,8 @@ static void enqueue_packet(RTPDemuxContext *s, uint8_t *buf, int len)
packet->next = *cur;
*cur = packet;
s->queue_len++;
+
+ return 0;
}
static int has_next_packet(RTPDemuxContext *s)
@@ -804,7 +806,9 @@ static int rtp_parse_one_packet(RTPDemuxContext *s, AVPacket *pkt,
return rv;
} else {
/* Still missing some packet, enqueue this one. */
- enqueue_packet(s, buf, len);
+ rv = enqueue_packet(s, buf, len);
+ if (rv < 0)
+ return rv;
*bufptr = NULL;
/* Return the first enqueued packet if the queue is full,
* even if we're missing something */