[FFmpeg-cvslog] avcodec/bitstream: Dont try to free buffers for static VLCs

Michael Niedermayer git at videolan.org
Thu Aug 8 15:14:34 CEST 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu Aug  8 15:05:48 2013 +0200| [9386f334af535634906168d765f1fe6fe105b4ed] | committer: Michael Niedermayer

avcodec/bitstream: Dont try to free buffers for static VLCs

Such buffers are not malloced thus freeing would be bad.
Note though this condition never could have happened so this
is more for correctness sake and not a true bugfix

Fixes CID1061047

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

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

 libavcodec/bitstream.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c
index 859dc62..299ee23 100644
--- a/libavcodec/bitstream.c
+++ b/libavcodec/bitstream.c
@@ -304,13 +304,15 @@ int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
             continue;                                                       \
         if (buf[j].bits > 3*nb_bits || buf[j].bits>32) {                    \
             av_log(NULL, AV_LOG_ERROR, "Too long VLC (%d) in init_vlc\n", buf[j].bits);\
-            av_free(buf);                                                   \
+            if (!(flags & INIT_VLC_USE_NEW_STATIC))                         \
+                av_free(buf);                                               \
             return -1;                                                      \
         }                                                                   \
         GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size);            \
         if (buf[j].code >= (1LL<<buf[j].bits)) {                            \
             av_log(NULL, AV_LOG_ERROR, "Invalid code in init_vlc\n");       \
-            av_free(buf);                                                   \
+            if (!(flags & INIT_VLC_USE_NEW_STATIC))                         \
+                av_free(buf);                                               \
             return -1;                                                      \
         }                                                                   \
         if (flags & INIT_VLC_LE)                                            \



More information about the ffmpeg-cvslog mailing list