comparison wavpack.c @ 4690:1bfdcac74275 libavcodec

Correctly handle data_size on decoding
author kostya
date Tue, 20 Mar 2007 05:44:42 +0000
parents 41ee67dd4bef
children bba203d5c5e7
comparison
equal deleted inserted replaced
4689:c7828f1ae244 4690:1bfdcac74275
381 int samplecount; 381 int samplecount;
382 int got_terms = 0, got_weights = 0, got_samples = 0, got_entropy = 0, got_bs = 0; 382 int got_terms = 0, got_weights = 0, got_samples = 0, got_entropy = 0, got_bs = 0;
383 uint8_t* buf_end = buf + buf_size; 383 uint8_t* buf_end = buf + buf_size;
384 int i, j, id, size, ssize, weights, t; 384 int i, j, id, size, ssize, weights, t;
385 385
386 if (buf_size == 0) return 0; 386 if (buf_size == 0){
387 *data_size = 0;
388 return 0;
389 }
387 390
388 memset(s->decorr, 0, MAX_TERMS * sizeof(Decorr)); 391 memset(s->decorr, 0, MAX_TERMS * sizeof(Decorr));
389 392
390 s->samples = AV_RL32(buf); buf += 4; 393 s->samples = AV_RL32(buf); buf += 4;
391 if(!s->samples) return buf_size; 394 if(!s->samples){
395 *data_size = 0;
396 return buf_size;
397 }
392 /* should not happen but who knows */ 398 /* should not happen but who knows */
393 if(s->samples * 2 * avctx->channels > AVCODEC_MAX_AUDIO_FRAME_SIZE){ 399 if(s->samples * 2 * avctx->channels > *data_size){
394 av_log(avctx, AV_LOG_ERROR, "Packet size is too big to be handled in lavc!\n"); 400 av_log(avctx, AV_LOG_ERROR, "Packet size is too big to be handled in lavc!\n");
395 return -1; 401 return -1;
396 } 402 }
397 s->joint = AV_RL32(buf) & WV_JOINT; buf += 4; 403 s->joint = AV_RL32(buf) & WV_JOINT; buf += 4;
398 s->CRC = AV_RL32(buf); buf += 4; 404 s->CRC = AV_RL32(buf); buf += 4;