avpacket: Check buffer reference
authorVittorio Giovara <vittorio.giovara@gmail.com>
Mon, 2 Feb 2015 19:53:51 +0000 (20:53 +0100)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Tue, 17 Feb 2015 17:16:43 +0000 (12:16 -0500)
CC: libav-stable@libav.org
Bug-Id: CID 1267889

libavcodec/avpacket.c

index 25eabdb..557258d 100644 (file)
@@ -365,8 +365,13 @@ int av_packet_ref(AVPacket *dst, AVPacket *src)
         if (ret < 0)
             goto fail;
         memcpy(dst->buf->data, src->data, src->size);
-    } else
+    } else {
         dst->buf = av_buffer_ref(src->buf);
+        if (!dst->buf) {
+            ret = AVERROR(ENOMEM);
+            goto fail;
+        }
+    }
 
     dst->size = src->size;
     dst->data = dst->buf->data;