libavcodec/ac3enc.c:2194: error: Buffer Overrun L2
  Offset: [min(-1, `avctx->priv_data->lfe_channel`), max(6, `avctx->priv_data->lfe_channel`)] Size: 6 by call to `set_bandwidth`.

libavcodec/ac3enc.c:2164:1: Parameter `avctx->priv_data->lfe_channel`
2162.  * Initialize the encoder.
2163.  */
2164. static av_cold int ac3_encode_init(AVCodecContext *avctx)
      ^
2165. {
2166.     AC3EncodeContext *s = avctx->priv_data;

libavcodec/ac3enc.c:2173:11: Call
2171.     ff_ac3_common_init();
2172. 
2173.     ret = validate_options(avctx, s);
                ^
2174.     if (ret)
2175.         return ret;

libavcodec/ac3enc.c:1969:1: Parameter `s->lfe_channel`
  1967. 
  1968. 
  1969. static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s)
        ^
  1970. {
  1971.     int i, ret;

libavcodec/ac3enc.c:1979:11: Call
  1977.                                       "might be incorrect.\n");
  1978.     }
  1979.     ret = set_channel_info(s, avctx->channels, &avctx->channel_layout);
                  ^
  1980.     if (ret) {
  1981.         av_log(avctx, AV_LOG_ERROR, "invalid channel layout\n");

libavcodec/ac3enc.c:1924:1: Parameter `s->lfe_channel`
    1922.  * Set channel information during initialization.
    1923.  */
    1924. static av_cold int set_channel_info(AC3EncodeContext *s, int channels,
          ^
    1925.                                     int64_t *channel_layout)
    1926. {

libavcodec/ac3enc.c:2194:5: Call
2192.     }
2193. 
2194.     set_bandwidth(s);
          ^
2195. 
2196.     exponent_init(s);

libavcodec/ac3enc.c:2048:1: <Offset trace>
2046.  * default value will be used.
2047.  */
2048. static av_cold void set_bandwidth(AC3EncodeContext *s)
      ^
2049. {
2050.     int ch;

libavcodec/ac3enc.c:2048:1: Parameter `s->lfe_channel`
  2046.  * default value will be used.
  2047.  */
  2048. static av_cold void set_bandwidth(AC3EncodeContext *s)
        ^
  2049. {
  2050.     int ch;

libavcodec/ac3enc.c:2048:1: <Length trace>
2046.  * default value will be used.
2047.  */
2048. static av_cold void set_bandwidth(AC3EncodeContext *s)
      ^
2049. {
2050.     int ch;

libavcodec/ac3enc.c:2048:1: Parameter `s->nb_coefs[*]`
  2046.  * default value will be used.
  2047.  */
  2048. static av_cold void set_bandwidth(AC3EncodeContext *s)
        ^
  2049. {
  2050.     int ch;

libavcodec/ac3enc.c:2067:9: Array access: Offset: [min(-1, avctx->priv_data->lfe_channel), max(6, avctx->priv_data->lfe_channel)] Size: 6 by call to `set_bandwidth` 
  2065.     }
  2066.     if (s->lfe_on)
  2067.         s->nb_coefs[s->lfe_channel] = 7; /* LFE channel always has 7 coefs */
                ^
  2068. }
  2069. 

static av_cold void set_bandwidth(AC3EncodeContext *s)
{
    int ch;
    if (s->cutoff) {
        int fbw_coeffs;
        fbw_coeffs     = s->cutoff * 2 * AC3_MAX_COEFS / s->sample_rate;
        s->bandwidth_code = av_clip((fbw_coeffs - 73) / 3, 0, 60);
    } else {
        s->bandwidth_code = ac3_bandwidth_tab[s->fbw_channels-1][s->bit_alloc.sr_code][s->frame_size_code/2];
    }
    for (ch = 0; ch < s->fbw_channels; ch++) {
        s->nb_coefs[ch] = s->bandwidth_code * 3 + 73;
    }
    if (s->lfe_on)
        s->nb_coefs[s->lfe_channel] = 7;
}
['static av_cold int ac3_encode_init(AVCodecContext *avctx)\n{\n    AC3EncodeContext *s = avctx->priv_data;\n    int ret, frame_size_58;\n    avctx->frame_size = AC3_FRAME_SIZE;\n    ff_ac3_common_init();\n    ret = validate_options(avctx, s);\n    if (ret)\n        return ret;\n    s->bitstream_mode = avctx->audio_service_type;\n    if (s->bitstream_mode == AV_AUDIO_SERVICE_TYPE_KARAOKE)\n        s->bitstream_mode = 0x7;\n    s->frame_size_min  = 2 * ff_ac3_frame_size_tab[s->frame_size_code][s->bit_alloc.sr_code];\n    s->bits_written    = 0;\n    s->samples_written = 0;\n    s->frame_size      = s->frame_size_min;\n    frame_size_58 = (( s->frame_size    >> 2) + ( s->frame_size    >> 4)) << 1;\n    s->crc_inv[0] = pow_poly((CRC16_POLY >> 1), (8 * frame_size_58) - 16, CRC16_POLY);\n    if (s->bit_alloc.sr_code == 1) {\n        frame_size_58 = (((s->frame_size+2) >> 2) + ((s->frame_size+2) >> 4)) << 1;\n        s->crc_inv[1] = pow_poly((CRC16_POLY >> 1), (8 * frame_size_58) - 16, CRC16_POLY);\n    }\n    set_bandwidth(s);\n    exponent_init(s);\n    bit_alloc_init(s);\n    ret = mdct_init(avctx, &s->mdct, 9);\n    if (ret)\n        goto init_fail;\n    ret = allocate_buffers(avctx);\n    if (ret)\n        goto init_fail;\n    avctx->coded_frame= avcodec_alloc_frame();\n    dsputil_init(&s->dsp, avctx);\n    ff_ac3dsp_init(&s->ac3dsp, avctx->flags & CODEC_FLAG_BITEXACT);\n    dprint_options(avctx);\n    return 0;\ninit_fail:\n    ac3_encode_close(avctx);\n    return ret;\n}', 'static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s)\n{\n    int i, ret;\n    if (!avctx->channel_layout) {\n        av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The "\n                                      "encoder will guess the layout, but it "\n                                      "might be incorrect.\\n");\n    }\n    ret = set_channel_info(s, avctx->channels, &avctx->channel_layout);\n    if (ret) {\n        av_log(avctx, AV_LOG_ERROR, "invalid channel layout\\n");\n        return ret;\n    }\n    for (i = 0; i < 9; i++) {\n        if ((ff_ac3_sample_rate_tab[i / 3] >> (i % 3)) == avctx->sample_rate)\n            break;\n    }\n    if (i == 9) {\n        av_log(avctx, AV_LOG_ERROR, "invalid sample rate\\n");\n        return AVERROR(EINVAL);\n    }\n    s->sample_rate        = avctx->sample_rate;\n    s->bit_alloc.sr_shift = i % 3;\n    s->bit_alloc.sr_code  = i / 3;\n    s->bitstream_id       = 8 + s->bit_alloc.sr_shift;\n    for (i = 0; i < 19; i++) {\n        if ((ff_ac3_bitrate_tab[i] >> s->bit_alloc.sr_shift)*1000 == avctx->bit_rate)\n            break;\n    }\n    if (i == 19) {\n        av_log(avctx, AV_LOG_ERROR, "invalid bit rate\\n");\n        return AVERROR(EINVAL);\n    }\n    s->bit_rate        = avctx->bit_rate;\n    s->frame_size_code = i << 1;\n    if (avctx->cutoff < 0) {\n        av_log(avctx, AV_LOG_ERROR, "invalid cutoff frequency\\n");\n        return AVERROR(EINVAL);\n    }\n    s->cutoff = avctx->cutoff;\n    if (s->cutoff > (s->sample_rate >> 1))\n        s->cutoff = s->sample_rate >> 1;\n    if ((avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_KARAOKE &&\n         avctx->channels == 1) ||\n        ((avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_COMMENTARY ||\n          avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_EMERGENCY  ||\n          avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_VOICE_OVER)\n         && avctx->channels > 1)) {\n        av_log(avctx, AV_LOG_ERROR, "invalid audio service type for the "\n                                    "specified number of channels\\n");\n        return AVERROR(EINVAL);\n    }\n    ret = validate_metadata(avctx);\n    if (ret)\n        return ret;\n    s->rematrixing_enabled = s->options.stereo_rematrixing &&\n                             (s->channel_mode == AC3_CHMODE_STEREO);\n    return 0;\n}', 'static av_cold int set_channel_info(AC3EncodeContext *s, int channels,\n                                    int64_t *channel_layout)\n{\n    int ch_layout;\n    if (channels < 1 || channels > AC3_MAX_CHANNELS)\n        return AVERROR(EINVAL);\n    if ((uint64_t)*channel_layout > 0x7FF)\n        return AVERROR(EINVAL);\n    ch_layout = *channel_layout;\n    if (!ch_layout)\n        ch_layout = avcodec_guess_channel_layout(channels, CODEC_ID_AC3, NULL);\n    s->lfe_on       = !!(ch_layout & AV_CH_LOW_FREQUENCY);\n    s->channels     = channels;\n    s->fbw_channels = channels - s->lfe_on;\n    s->lfe_channel  = s->lfe_on ? s->fbw_channels : -1;\n    if (s->lfe_on)\n        ch_layout -= AV_CH_LOW_FREQUENCY;\n    switch (ch_layout) {\n    case AV_CH_LAYOUT_MONO:           s->channel_mode = AC3_CHMODE_MONO;   break;\n    case AV_CH_LAYOUT_STEREO:         s->channel_mode = AC3_CHMODE_STEREO; break;\n    case AV_CH_LAYOUT_SURROUND:       s->channel_mode = AC3_CHMODE_3F;     break;\n    case AV_CH_LAYOUT_2_1:            s->channel_mode = AC3_CHMODE_2F1R;   break;\n    case AV_CH_LAYOUT_4POINT0:        s->channel_mode = AC3_CHMODE_3F1R;   break;\n    case AV_CH_LAYOUT_QUAD:\n    case AV_CH_LAYOUT_2_2:            s->channel_mode = AC3_CHMODE_2F2R;   break;\n    case AV_CH_LAYOUT_5POINT0:\n    case AV_CH_LAYOUT_5POINT0_BACK:   s->channel_mode = AC3_CHMODE_3F2R;   break;\n    default:\n        return AVERROR(EINVAL);\n    }\n    s->has_center   = (s->channel_mode & 0x01) && s->channel_mode != AC3_CHMODE_MONO;\n    s->has_surround =  s->channel_mode & 0x04;\n    s->channel_map  = ff_ac3_enc_channel_map[s->channel_mode][s->lfe_on];\n    *channel_layout = ch_layout;\n    if (s->lfe_on)\n        *channel_layout |= AV_CH_LOW_FREQUENCY;\n    return 0;\n}', 'static av_cold void set_bandwidth(AC3EncodeContext *s)\n{\n    int ch;\n    if (s->cutoff) {\n        int fbw_coeffs;\n        fbw_coeffs     = s->cutoff * 2 * AC3_MAX_COEFS / s->sample_rate;\n        s->bandwidth_code = av_clip((fbw_coeffs - 73) / 3, 0, 60);\n    } else {\n        s->bandwidth_code = ac3_bandwidth_tab[s->fbw_channels-1][s->bit_alloc.sr_code][s->frame_size_code/2];\n    }\n    for (ch = 0; ch < s->fbw_channels; ch++) {\n        s->nb_coefs[ch] = s->bandwidth_code * 3 + 73;\n    }\n    if (s->lfe_on)\n        s->nb_coefs[s->lfe_channel] = 7;\n}']