libavcodec/alac.c:464: error: Integer Overflow L2
  ([1, -1+min(2147483647, `avctx->priv_data->setinfo_max_samples_per_frame`)] × 4):signed32 by call to `predictor_decompress_fir_adapt`.

libavcodec/alac.c:350:1: Parameter `avctx->priv_data->setinfo_max_samples_per_frame`
348. }
349. 
350. static int alac_decode_frame(AVCodecContext *avctx, void *data,
     ^
351.                              int *got_frame_ptr, AVPacket *avpkt)
352. {

libavcodec/alac.c:464:17: Call
462.                  * reference encoder.
463.                  */
464.                 predictor_decompress_fir_adapt(alac->predicterror_buffer[ch],
                     ^
465.                                                alac->predicterror_buffer[ch],
466.                                                outputsamples, readsamplesize,

libavcodec/alac.c:185:1: <LHS trace>
183. }
184. 
185. static void predictor_decompress_fir_adapt(int32_t *error_buffer,
     ^
186.                                            int32_t *buffer_out,
187.                                            int output_size,

libavcodec/alac.c:185:1: Parameter `output_size`
  183. }
  184. 
  185. static void predictor_decompress_fir_adapt(int32_t *error_buffer,
       ^
  186.                                            int32_t *buffer_out,
  187.                                            int output_size,

libavcodec/alac.c:202:9: Binary operation: ([1, -1+min(2147483647, avctx->priv_data->setinfo_max_samples_per_frame)] × 4):signed32 by call to `predictor_decompress_fir_adapt` 
  200.             return;
  201. 
  202.         memcpy(buffer_out+1, error_buffer+1, (output_size-1) * 4);
               ^
  203.         return;
  204.     }

static void predictor_decompress_fir_adapt(int32_t *error_buffer,
                                           int32_t *buffer_out,
                                           int output_size,
                                           int readsamplesize,
                                           int16_t *predictor_coef_table,
                                           int predictor_coef_num,
                                           int predictor_quantitization)
{
    int i;
    *buffer_out = *error_buffer;
    if (!predictor_coef_num) {
        if (output_size <= 1)
            return;
        memcpy(buffer_out+1, error_buffer+1, (output_size-1) * 4);
        return;
    }
    if (predictor_coef_num == 0x1f) {
        if (output_size <= 1)
            return;
        for (i = 0; i < output_size - 1; i++) {
            int32_t prev_value;
            int32_t error_value;
            prev_value = buffer_out[i];
            error_value = error_buffer[i+1];
            buffer_out[i+1] =
                sign_extend((prev_value + error_value), readsamplesize);
        }
        return;
    }
    if (predictor_coef_num > 0)
        for (i = 0; i < predictor_coef_num; i++) {
            int32_t val;
            val = buffer_out[i] + error_buffer[i+1];
            val = sign_extend(val, readsamplesize);
            buffer_out[i+1] = val;
        }
    if (predictor_coef_num > 0) {
        for (i = predictor_coef_num + 1; i < output_size; i++) {
            int j;
            int sum = 0;
            int outval;
            int error_val = error_buffer[i];
            for (j = 0; j < predictor_coef_num; j++) {
                sum += (buffer_out[predictor_coef_num-j] - buffer_out[0]) *
                       predictor_coef_table[j];
            }
            outval = (1 << (predictor_quantitization-1)) + sum;
            outval = outval >> predictor_quantitization;
            outval = outval + buffer_out[0] + error_val;
            outval = sign_extend(outval, readsamplesize);
            buffer_out[predictor_coef_num+1] = outval;
            if (error_val > 0) {
                int predictor_num = predictor_coef_num - 1;
                while (predictor_num >= 0 && error_val > 0) {
                    int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num];
                    int sign = sign_only(val);
                    predictor_coef_table[predictor_num] -= sign;
                    val *= sign;
                    error_val -= ((val >> predictor_quantitization) *
                                  (predictor_coef_num - predictor_num));
                    predictor_num--;
                }
            } else if (error_val < 0) {
                int predictor_num = predictor_coef_num - 1;
                while (predictor_num >= 0 && error_val < 0) {
                    int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num];
                    int sign = - sign_only(val);
                    predictor_coef_table[predictor_num] -= sign;
                    val *= sign;
                    error_val -= ((val >> predictor_quantitization) *
                                  (predictor_coef_num - predictor_num));
                    predictor_num--;
                }
            }
            buffer_out++;
        }
    }
}
['static int alac_decode_frame(AVCodecContext *avctx, void *data,\n                             int *got_frame_ptr, AVPacket *avpkt)\n{\n    const uint8_t *inbuffer = avpkt->data;\n    int input_buffer_size = avpkt->size;\n    ALACContext *alac = avctx->priv_data;\n    int channels;\n    unsigned int outputsamples;\n    int hassize;\n    unsigned int readsamplesize;\n    int isnotcompressed;\n    uint8_t interlacing_shift;\n    uint8_t interlacing_leftweight;\n    int i, ch, ret;\n    init_get_bits(&alac->gb, inbuffer, input_buffer_size * 8);\n    channels = get_bits(&alac->gb, 3) + 1;\n    if (channels != avctx->channels) {\n        av_log(avctx, AV_LOG_ERROR, "frame header channel count mismatch\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    skip_bits(&alac->gb, 4);\n    skip_bits(&alac->gb, 12);\n    hassize = get_bits1(&alac->gb);\n    alac->extra_bits = get_bits(&alac->gb, 2) << 3;\n    isnotcompressed = get_bits1(&alac->gb);\n    if (hassize) {\n        outputsamples = get_bits_long(&alac->gb, 32);\n        if(outputsamples > alac->setinfo_max_samples_per_frame){\n            av_log(avctx, AV_LOG_ERROR, "outputsamples %d > %d\\n", outputsamples, alac->setinfo_max_samples_per_frame);\n            return -1;\n        }\n    } else\n        outputsamples = alac->setinfo_max_samples_per_frame;\n    if (outputsamples > INT32_MAX) {\n        av_log(avctx, AV_LOG_ERROR, "unsupported block size: %u\\n", outputsamples);\n        return AVERROR_INVALIDDATA;\n    }\n    alac->frame.nb_samples = outputsamples;\n    if ((ret = avctx->get_buffer(avctx, &alac->frame)) < 0) {\n        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\\n");\n        return ret;\n    }\n    readsamplesize = alac->setinfo_sample_size - alac->extra_bits + channels - 1;\n    if (readsamplesize > MIN_CACHE_BITS) {\n        av_log(avctx, AV_LOG_ERROR, "readsamplesize too big (%d)\\n", readsamplesize);\n        return -1;\n    }\n    if (!isnotcompressed) {\n        int16_t predictor_coef_table[MAX_CHANNELS][32];\n        int predictor_coef_num[MAX_CHANNELS];\n        int prediction_type[MAX_CHANNELS];\n        int prediction_quantitization[MAX_CHANNELS];\n        int ricemodifier[MAX_CHANNELS];\n        interlacing_shift = get_bits(&alac->gb, 8);\n        interlacing_leftweight = get_bits(&alac->gb, 8);\n        for (ch = 0; ch < channels; ch++) {\n            prediction_type[ch] = get_bits(&alac->gb, 4);\n            prediction_quantitization[ch] = get_bits(&alac->gb, 4);\n            ricemodifier[ch] = get_bits(&alac->gb, 3);\n            predictor_coef_num[ch] = get_bits(&alac->gb, 5);\n            for (i = 0; i < predictor_coef_num[ch]; i++)\n                predictor_coef_table[ch][i] = (int16_t)get_bits(&alac->gb, 16);\n        }\n        if (alac->extra_bits) {\n            for (i = 0; i < outputsamples; i++) {\n                for (ch = 0; ch < channels; ch++)\n                    alac->extra_bits_buffer[ch][i] = get_bits(&alac->gb, alac->extra_bits);\n            }\n        }\n        for (ch = 0; ch < channels; ch++) {\n            bastardized_rice_decompress(alac,\n                                        alac->predicterror_buffer[ch],\n                                        outputsamples,\n                                        readsamplesize,\n                                        alac->setinfo_rice_initialhistory,\n                                        alac->setinfo_rice_kmodifier,\n                                        ricemodifier[ch] * alac->setinfo_rice_historymult / 4,\n                                        (1 << alac->setinfo_rice_kmodifier) - 1);\n            if (prediction_type[ch] == 15) {\n                predictor_decompress_fir_adapt(alac->predicterror_buffer[ch],\n                                               alac->predicterror_buffer[ch],\n                                               outputsamples, readsamplesize,\n                                               NULL, 31, 0);\n            } else if (prediction_type[ch] > 0) {\n                av_log(avctx, AV_LOG_WARNING, "unknown prediction type: %i\\n",\n                       prediction_type[ch]);\n            }\n            predictor_decompress_fir_adapt(alac->predicterror_buffer[ch],\n                                           alac->outputsamples_buffer[ch],\n                                           outputsamples, readsamplesize,\n                                           predictor_coef_table[ch],\n                                           predictor_coef_num[ch],\n                                           prediction_quantitization[ch]);\n        }\n    } else {\n        for (i = 0; i < outputsamples; i++) {\n            for (ch = 0; ch < channels; ch++) {\n                alac->outputsamples_buffer[ch][i] = get_sbits_long(&alac->gb,\n                                                                   alac->setinfo_sample_size);\n            }\n        }\n        alac->extra_bits = 0;\n        interlacing_shift = 0;\n        interlacing_leftweight = 0;\n    }\n    if (get_bits(&alac->gb, 3) != 7)\n        av_log(avctx, AV_LOG_ERROR, "Error : Wrong End Of Frame\\n");\n    if (channels == 2 && interlacing_leftweight) {\n        decorrelate_stereo(alac->outputsamples_buffer, outputsamples,\n                           interlacing_shift, interlacing_leftweight);\n    }\n    if (alac->extra_bits) {\n        append_extra_bits(alac->outputsamples_buffer, alac->extra_bits_buffer,\n                          alac->extra_bits, alac->numchannels, outputsamples);\n    }\n    switch(alac->setinfo_sample_size) {\n    case 16:\n        if (channels == 2) {\n            interleave_stereo_16(alac->outputsamples_buffer,\n                                 (int16_t *)alac->frame.data[0], outputsamples);\n        } else {\n            int16_t *outbuffer = (int16_t *)alac->frame.data[0];\n            for (i = 0; i < outputsamples; i++) {\n                outbuffer[i] = alac->outputsamples_buffer[0][i];\n            }\n        }\n        break;\n    case 24:\n        if (channels == 2) {\n            interleave_stereo_24(alac->outputsamples_buffer,\n                                 (int32_t *)alac->frame.data[0], outputsamples);\n        } else {\n            int32_t *outbuffer = (int32_t *)alac->frame.data[0];\n            for (i = 0; i < outputsamples; i++)\n                outbuffer[i] = alac->outputsamples_buffer[0][i] << 8;\n        }\n        break;\n    }\n    if (input_buffer_size * 8 - get_bits_count(&alac->gb) > 8)\n        av_log(avctx, AV_LOG_ERROR, "Error : %d bits left\\n", input_buffer_size * 8 - get_bits_count(&alac->gb));\n    *got_frame_ptr   = 1;\n    *(AVFrame *)data = alac->frame;\n    return input_buffer_size;\n}', 'static void predictor_decompress_fir_adapt(int32_t *error_buffer,\n                                           int32_t *buffer_out,\n                                           int output_size,\n                                           int readsamplesize,\n                                           int16_t *predictor_coef_table,\n                                           int predictor_coef_num,\n                                           int predictor_quantitization)\n{\n    int i;\n    *buffer_out = *error_buffer;\n    if (!predictor_coef_num) {\n        if (output_size <= 1)\n            return;\n        memcpy(buffer_out+1, error_buffer+1, (output_size-1) * 4);\n        return;\n    }\n    if (predictor_coef_num == 0x1f) {\n        if (output_size <= 1)\n            return;\n        for (i = 0; i < output_size - 1; i++) {\n            int32_t prev_value;\n            int32_t error_value;\n            prev_value = buffer_out[i];\n            error_value = error_buffer[i+1];\n            buffer_out[i+1] =\n                sign_extend((prev_value + error_value), readsamplesize);\n        }\n        return;\n    }\n    if (predictor_coef_num > 0)\n        for (i = 0; i < predictor_coef_num; i++) {\n            int32_t val;\n            val = buffer_out[i] + error_buffer[i+1];\n            val = sign_extend(val, readsamplesize);\n            buffer_out[i+1] = val;\n        }\n    if (predictor_coef_num > 0) {\n        for (i = predictor_coef_num + 1; i < output_size; i++) {\n            int j;\n            int sum = 0;\n            int outval;\n            int error_val = error_buffer[i];\n            for (j = 0; j < predictor_coef_num; j++) {\n                sum += (buffer_out[predictor_coef_num-j] - buffer_out[0]) *\n                       predictor_coef_table[j];\n            }\n            outval = (1 << (predictor_quantitization-1)) + sum;\n            outval = outval >> predictor_quantitization;\n            outval = outval + buffer_out[0] + error_val;\n            outval = sign_extend(outval, readsamplesize);\n            buffer_out[predictor_coef_num+1] = outval;\n            if (error_val > 0) {\n                int predictor_num = predictor_coef_num - 1;\n                while (predictor_num >= 0 && error_val > 0) {\n                    int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num];\n                    int sign = sign_only(val);\n                    predictor_coef_table[predictor_num] -= sign;\n                    val *= sign;\n                    error_val -= ((val >> predictor_quantitization) *\n                                  (predictor_coef_num - predictor_num));\n                    predictor_num--;\n                }\n            } else if (error_val < 0) {\n                int predictor_num = predictor_coef_num - 1;\n                while (predictor_num >= 0 && error_val < 0) {\n                    int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num];\n                    int sign = - sign_only(val);\n                    predictor_coef_table[predictor_num] -= sign;\n                    val *= sign;\n                    error_val -= ((val >> predictor_quantitization) *\n                                  (predictor_coef_num - predictor_num));\n                    predictor_num--;\n                }\n            }\n            buffer_out++;\n        }\n    }\n}']