[FFmpeg-cvslog] avpacket: Fix error checking in packet_alloc

Martin Storsjö git at videolan.org
Mon Sep 16 14:29:49 CEST 2013


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Wed Sep 11 23:09:37 2013 +0300| [85e8192b8593816c0445411a5bef5fc5363a9b6d] | committer: Martin Storsjö

avpacket: Fix error checking in packet_alloc

Previously the wrong buffer pointer was checked, when buf
instead of *buf was checked. But checking the return value
instead is even better.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable at libav.org
Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=85e8192b8593816c0445411a5bef5fc5363a9b6d
---

 libavcodec/avpacket.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 79123b1..c0a0f8c 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -64,12 +64,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 static int packet_alloc(AVBufferRef **buf, int size)
 {
+    int ret;
     if ((unsigned)size >= (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
         return AVERROR(EINVAL);
 
-    av_buffer_realloc(buf, size + FF_INPUT_BUFFER_PADDING_SIZE);
-    if (!buf)
-        return AVERROR(ENOMEM);
+    ret = av_buffer_realloc(buf, size + FF_INPUT_BUFFER_PADDING_SIZE);
+    if (ret < 0)
+        return ret;
 
     memset((*buf)->data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
 



More information about the ffmpeg-cvslog mailing list