Revision f39ab207

View differences:

libavcodec/bitstream.c
275 275
             const void *symbols, int symbols_wrap, int symbols_size,
276 276
             int flags)
277 277
{
278
    VLCcode buf[nb_codes];
279
    int i, j;
278
    VLCcode *buf;
279
    int i, j, ret;
280 280

  
281 281
    vlc->bits = nb_bits;
282 282
    if(flags & INIT_VLC_USE_NEW_STATIC){
......
295 295
    av_log(NULL,AV_LOG_DEBUG,"build table nb_codes=%d\n", nb_codes);
296 296
#endif
297 297

  
298
    buf = av_malloc((nb_codes+1)*sizeof(VLCcode));
299

  
298 300
    assert(symbols_size <= 2 || !symbols);
299 301
    j = 0;
300 302
#define COPY(condition)\
......
319 321
    COPY(buf[j].bits && buf[j].bits <= nb_bits);
320 322
    nb_codes = j;
321 323

  
322
    if (build_table(vlc, nb_bits, nb_codes, buf, flags) < 0) {
324
    ret = build_table(vlc, nb_bits, nb_codes, buf, flags);
325

  
326
    av_free(buf);
327
    if (ret < 0) {
323 328
        av_freep(&vlc->table);
324 329
        return -1;
325 330
    }

Also available in: Unified diff