Revision e30004fa libavcodec/huffyuv.c

View differences:

libavcodec/huffyuv.c
213 213
    *blue=  src[(w-1)*4+B];
214 214
}
215 215

  
216
static void read_len_table(uint8_t *dst, GetBitContext *gb){
216
static int read_len_table(uint8_t *dst, GetBitContext *gb){
217 217
    int i, val, repeat;
218 218

  
219 219
    for(i=0; i<256;){
......
222 222
        if(repeat==0)
223 223
            repeat= get_bits(gb, 8);
224 224
//printf("%d %d\n", val, repeat);
225
        if(i+repeat > 256) {
226
            av_log(NULL, AV_LOG_ERROR, "Error reading huffman table\n");
227
            return -1;
228
        }
225 229
        while (repeat--)
226 230
            dst[i++] = val;
227 231
    }
232
    return 0;
228 233
}
229 234

  
230 235
static int generate_bits_table(uint32_t *dst, uint8_t *len_table){
......
379 384
    init_get_bits(&gb, src, length*8);
380 385

  
381 386
    for(i=0; i<3; i++){
382
        read_len_table(s->len[i], &gb);
383

  
387
        if(read_len_table(s->len[i], &gb)<0)
388
            return -1;
384 389
        if(generate_bits_table(s->bits[i], s->len[i])<0){
385 390
            return -1;
386 391
        }
......
404 409
    int i;
405 410

  
406 411
    init_get_bits(&gb, classic_shift_luma, sizeof(classic_shift_luma)*8);
407
    read_len_table(s->len[0], &gb);
412
    if(read_len_table(s->len[0], &gb)<0)
413
        return -1;
408 414
    init_get_bits(&gb, classic_shift_chroma, sizeof(classic_shift_chroma)*8);
409
    read_len_table(s->len[1], &gb);
415
    if(read_len_table(s->len[1], &gb)<0)
416
        return -1;
410 417

  
411 418
    for(i=0; i<256; i++) s->bits[0][i] = classic_add_luma  [i];
412 419
    for(i=0; i<256; i++) s->bits[1][i] = classic_add_chroma[i];

Also available in: Unified diff