avcodec/pthread: check packet buffer allocation
authorHendrik Leppkes <h.leppkes@gmail.com>
Sun, 24 Nov 2013 20:50:19 +0000 (21:50 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 25 Nov 2013 01:22:43 +0000 (02:22 +0100)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/pthread_frame.c

index 4f9d68b..6af05e2 100644 (file)
@@ -343,6 +343,10 @@ static int submit_packet(PerThreadContext *p, AVPacket *avpkt)
         p->avpkt.buf = av_buffer_ref(avpkt->buf);
     else {
         av_fast_malloc(&p->buf, &p->allocated_buf_size, avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE);
+        if (!p->buf) {
+            pthread_mutex_unlock(&p->mutex);
+            return AVERROR(ENOMEM);
+        }
         p->avpkt.data = p->buf;
         memcpy(p->buf, avpkt->data, avpkt->size);
         memset(p->buf + avpkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);