comparison mlpdec.c @ 9532:2aabf1a58f19 libavcodec

mlpdec: Validate num_primitive_matrices.
author ramiro
date Tue, 21 Apr 2009 22:32:50 +0000
parents 19a70bcc2220
children b724134599eb
comparison
equal deleted inserted replaced
9531:19a70bcc2220 9532:2aabf1a58f19
525 525
526 static int read_matrix_params(MLPDecodeContext *m, unsigned int substr, GetBitContext *gbp) 526 static int read_matrix_params(MLPDecodeContext *m, unsigned int substr, GetBitContext *gbp)
527 { 527 {
528 SubStream *s = &m->substream[substr]; 528 SubStream *s = &m->substream[substr];
529 unsigned int mat, ch; 529 unsigned int mat, ch;
530 const int max_primitive_matrices = m->avctx->codec_id == CODEC_ID_MLP
531 ? MAX_MATRICES_MLP
532 : MAX_MATRICES_TRUEHD;
530 533
531 if (m->matrix_changed++ > 1) { 534 if (m->matrix_changed++ > 1) {
532 av_log(m->avctx, AV_LOG_ERROR, "Matrices may change only once per access unit.\n"); 535 av_log(m->avctx, AV_LOG_ERROR, "Matrices may change only once per access unit.\n");
533 return -1; 536 return -1;
534 } 537 }
535 538
536 s->num_primitive_matrices = get_bits(gbp, 4); 539 s->num_primitive_matrices = get_bits(gbp, 4);
540
541 if (s->num_primitive_matrices > max_primitive_matrices) {
542 av_log(m->avctx, AV_LOG_ERROR,
543 "Number of primitive matrices cannot be greater than %d.\n",
544 max_primitive_matrices);
545 return -1;
546 }
537 547
538 for (mat = 0; mat < s->num_primitive_matrices; mat++) { 548 for (mat = 0; mat < s->num_primitive_matrices; mat++) {
539 int frac_bits, max_chan; 549 int frac_bits, max_chan;
540 s->matrix_out_ch[mat] = get_bits(gbp, 4); 550 s->matrix_out_ch[mat] = get_bits(gbp, 4);
541 frac_bits = get_bits(gbp, 4); 551 frac_bits = get_bits(gbp, 4);