avcodec/pthread_frame: Check av_packet_ref() for failure
authorMichael Niedermayer <michael@niedermayer.cc>
Sun, 5 Feb 2017 14:09:52 +0000 (15:09 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 6 Feb 2017 00:01:33 +0000 (01:01 +0100)
Fixes CID1396242

libavcodec/pthread_frame.c

index cb6d762..272587f 100644 (file)
@@ -312,6 +312,7 @@ static int submit_packet(PerThreadContext *p, AVPacket *avpkt)
     FrameThreadContext *fctx = p->parent;
     PerThreadContext *prev_thread = fctx->prev_thread;
     const AVCodec *codec = p->avctx->codec;
+    int ret;
 
     if (!avpkt->size && !(codec->capabilities & AV_CODEC_CAP_DELAY))
         return 0;
@@ -337,7 +338,12 @@ static int submit_packet(PerThreadContext *p, AVPacket *avpkt)
     }
 
     av_packet_unref(&p->avpkt);
-    av_packet_ref(&p->avpkt, avpkt);
+    ret = av_packet_ref(&p->avpkt, avpkt);
+    if (ret < 0) {
+        pthread_mutex_unlock(&p->mutex);
+        av_log(p->avctx, AV_LOG_ERROR, "av_packet_ref() failed in submit_packet()\n");
+        return ret;
+    }
 
     p->state = STATE_SETTING_UP;
     pthread_cond_signal(&p->input_cond);