diff options
author | Loren Merritt <lorenm@u.washington.edu> | 2010-05-13 02:38:05 +0400 |
---|---|---|
committer | Loren Merritt <lorenm@u.washington.edu> | 2010-05-13 02:38:05 +0400 |
commit | f39ab2071fd1df6177e0e3403aa22fe0da161be8 (patch) | |
tree | 59beadc12f6f3c3fa41a035ff370afc4dea9cc42 /libavcodec/bitstream.c | |
parent | 7693b93e5ccec1d09170fcc27dcd71a32783447b (diff) |
change a variable-length array to a malloc.
Originally committed as revision 23103 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/bitstream.c')
-rw-r--r-- | libavcodec/bitstream.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c index 0d7a2dbc85..83f30f9799 100644 --- a/libavcodec/bitstream.c +++ b/libavcodec/bitstream.c @@ -275,8 +275,8 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, 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 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, 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 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, 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; } |