comparison ac3dec.c @ 8279:6c2dcc1410bb libavcodec

ac3: detect dba errors and prevent writing past end of array
author jbr
date Mon, 08 Dec 2008 03:13:20 +0000
parents e2ef97f0ab4b
children 63aba08af550
comparison
equal deleted inserted replaced
8278:24a49d3fdc3b 8279:6c2dcc1410bb
1131 s->psd[ch], s->band_psd[ch]); 1131 s->psd[ch], s->band_psd[ch]);
1132 } 1132 }
1133 if(bit_alloc_stages[ch] > 1) { 1133 if(bit_alloc_stages[ch] > 1) {
1134 /* Compute excitation function, Compute masking curve, and 1134 /* Compute excitation function, Compute masking curve, and
1135 Apply delta bit allocation */ 1135 Apply delta bit allocation */
1136 ff_ac3_bit_alloc_calc_mask(&s->bit_alloc_params, s->band_psd[ch], 1136 if (ff_ac3_bit_alloc_calc_mask(&s->bit_alloc_params, s->band_psd[ch],
1137 s->start_freq[ch], s->end_freq[ch], 1137 s->start_freq[ch], s->end_freq[ch],
1138 s->fast_gain[ch], (ch == s->lfe_ch), 1138 s->fast_gain[ch], (ch == s->lfe_ch),
1139 s->dba_mode[ch], s->dba_nsegs[ch], 1139 s->dba_mode[ch], s->dba_nsegs[ch],
1140 s->dba_offsets[ch], s->dba_lengths[ch], 1140 s->dba_offsets[ch], s->dba_lengths[ch],
1141 s->dba_values[ch], s->mask[ch]); 1141 s->dba_values[ch], s->mask[ch])) {
1142 av_log(s->avctx, AV_LOG_ERROR, "error in bit allocation\n");
1143 return -1;
1144 }
1142 } 1145 }
1143 if(bit_alloc_stages[ch] > 0) { 1146 if(bit_alloc_stages[ch] > 0) {
1144 /* Compute bit allocation */ 1147 /* Compute bit allocation */
1145 const uint8_t *bap_tab = s->channel_uses_aht[ch] ? 1148 const uint8_t *bap_tab = s->channel_uses_aht[ch] ?
1146 ff_eac3_hebap_tab : ff_ac3_bap_tab; 1149 ff_eac3_hebap_tab : ff_ac3_bap_tab;