Mercurial > libavcodec.hg
changeset 11713:b9354f343d2d libavcodec
change a variable-length array to a malloc.
author | lorenm |
---|---|
date | Wed, 12 May 2010 22:38:05 +0000 |
parents | 25ed71436974 |
children | 8ad2b8f20e6a |
files | bitstream.c |
diffstat | 1 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/bitstream.c Wed May 12 17:05:56 2010 +0000 +++ b/bitstream.c Wed May 12 22:38:05 2010 +0000 @@ -275,8 +275,8 @@ const void *symbols, int symbols_wrap, int symbols_size, int flags) { - VLCcode buf[nb_codes]; - int i, j; + VLCcode *buf; + int i, j, ret; vlc->bits = nb_bits; if(flags & INIT_VLC_USE_NEW_STATIC){ @@ -295,6 +295,8 @@ av_log(NULL,AV_LOG_DEBUG,"build table nb_codes=%d\n", nb_codes); #endif + buf = av_malloc((nb_codes+1)*sizeof(VLCcode)); + assert(symbols_size <= 2 || !symbols); j = 0; #define COPY(condition)\ @@ -319,7 +321,10 @@ COPY(buf[j].bits && buf[j].bits <= nb_bits); nb_codes = j; - if (build_table(vlc, nb_bits, nb_codes, buf, flags) < 0) { + ret = build_table(vlc, nb_bits, nb_codes, buf, flags); + + av_free(buf); + if (ret < 0) { av_freep(&vlc->table); return -1; }