[FFmpeg-cvslog] avcodec/avpacket: fix order of operations in case of too large allocation

Michael Niedermayer git at videolan.org
Wed Nov 20 19:51:43 CET 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Nov 20 19:44:21 2013 +0100| [e50278348a3144f7de217cede54fc24399a733f8] | committer: Michael Niedermayer

avcodec/avpacket: fix order of operations in case of too large allocation

Found-by: wm4
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

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

diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 88ec0be..7a6195c 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -442,9 +442,11 @@ uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size)
         const size_t new_size = *size + keylen + 1 + valuelen + 1;
         uint8_t *const new_data = av_realloc(data, new_size);
 
-        if (!new_data || new_size > INT_MAX)
+        if (!new_data)
             goto fail;
         data = new_data;
+        if (new_size > INT_MAX)
+            goto fail;
 
         memcpy(data + *size, t->key, keylen + 1);
         memcpy(data + *size + keylen + 1, t->value, valuelen + 1);



More information about the ffmpeg-cvslog mailing list