avconv.c:2155: error: Buffer Overrun L3
  Offset: 0 Size: [0, 2147483631] by call to `init_output_stream`.

avconv.c:2141:62: Call
2139.         if (ifile->rate_emu)
2140.             for (j = 0; j < ifile->nb_streams; j++)
2141.                 input_streams[j + ifile->ist_index]->start = av_gettime_relative();
                                                                   ^
2142.     }
2143. 

libavutil/time.c:62:5: Assignment
  60.     struct timespec ts;
  61.     clock_gettime(CLOCK_MONOTONIC, &ts);
  62.     return (int64_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
          ^
  63. #else
  64.     return av_gettime() + 42 * 60 * 60 * INT64_C(1000000);

avconv.c:2141:17: Assignment
2139.         if (ifile->rate_emu)
2140.             for (j = 0; j < ifile->nb_streams; j++)
2141.                 input_streams[j + ifile->ist_index]->start = av_gettime_relative();
                      ^
2142.     }
2143. 

avconv.c:2155:15: Call
2153.             continue;
2154. 
2155.         ret = init_output_stream(output_streams[i], error, sizeof(error));
                    ^
2156.         if (ret < 0)
2157.             goto dump_format;

avconv.c:2022:1: <Offset trace>
2020. }
2021. 
2022. static int init_output_stream(OutputStream *ost, char *error, int error_len)
      ^
2023. {
2024.     int ret = 0;

avconv.c:2022:1: Parameter `ost->enc_ctx->nb_coded_side_data`
  2020. }
  2021. 
  2022. static int init_output_stream(OutputStream *ost, char *error, int error_len)
        ^
  2023. {
  2024.     int ret = 0;

avconv.c:2077:34: <Length trace>
2075.             int i;
2076. 
2077.             ost->st->side_data = av_realloc_array(NULL, ost->enc_ctx->nb_coded_side_data,
                                       ^
2078.                                                   sizeof(*ost->st->side_data));
2079.             if (!ost->st->side_data)

avconv.c:2077:34: Call
  2075.             int i;
  2076. 
  2077.             ost->st->side_data = av_realloc_array(NULL, ost->enc_ctx->nb_coded_side_data,
                                         ^
  2078.                                                   sizeof(*ost->st->side_data));
  2079.             if (!ost->st->side_data)

libavutil/mem.c:164:9: Assignment
    162. {
    163.     if (!size || nmemb >= INT_MAX / size)
    164.         return NULL;
                 ^
    165.     return av_realloc(ptr, nmemb * size);
    166. }

avconv.c:2077:13: Assignment
  2075.             int i;
  2076. 
  2077.             ost->st->side_data = av_realloc_array(NULL, ost->enc_ctx->nb_coded_side_data,
                    ^
  2078.                                                   sizeof(*ost->st->side_data));
  2079.             if (!ost->st->side_data)

avconv.c:2084:17: Array access: Offset: 0 Size: [0, 2147483631] by call to `init_output_stream` 
  2082.             for (i = 0; i < ost->enc_ctx->nb_coded_side_data; i++) {
  2083.                 const AVPacketSideData *sd_src = &ost->enc_ctx->coded_side_data[i];
  2084.                 AVPacketSideData *sd_dst = &ost->st->side_data[i];
                        ^
  2085. 
  2086.                 sd_dst->data = av_malloc(sd_src->size);

static int init_output_stream(OutputStream *ost, char *error, int error_len)
{
    int ret = 0;
    if (ost->encoding_needed) {
        AVCodec      *codec = ost->enc;
        AVCodecContext *dec = NULL;
        InputStream *ist;
        ret = init_output_stream_encode(ost);
        if (ret < 0)
            return ret;
        if ((ist = get_input_stream(ost)))
            dec = ist->dec_ctx;
        if (dec && dec->subtitle_header) {
            ost->enc_ctx->subtitle_header = av_malloc(dec->subtitle_header_size);
            if (!ost->enc_ctx->subtitle_header)
                return AVERROR(ENOMEM);
            memcpy(ost->enc_ctx->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);
            ost->enc_ctx->subtitle_header_size = dec->subtitle_header_size;
        }
        if (!av_dict_get(ost->encoder_opts, "threads", NULL, 0))
            av_dict_set(&ost->encoder_opts, "threads", "auto", 0);
        if (ost->filter && ost->filter->filter->inputs[0]->hw_frames_ctx) {
            ost->enc_ctx->hw_frames_ctx = av_buffer_ref(ost->filter->filter->inputs[0]->hw_frames_ctx);
            if (!ost->enc_ctx->hw_frames_ctx)
                return AVERROR(ENOMEM);
        }
        if ((ret = avcodec_open2(ost->enc_ctx, codec, &ost->encoder_opts)) < 0) {
            if (ret == AVERROR_EXPERIMENTAL)
                abort_codec_experimental(codec, 1);
            snprintf(error, error_len,
                     "Error while opening encoder for output stream #%d:%d - "
                     "maybe incorrect parameters such as bit_rate, rate, width or height",
                    ost->file_index, ost->index);
            return ret;
        }
        assert_avoptions(ost->encoder_opts);
        if (ost->enc_ctx->bit_rate && ost->enc_ctx->bit_rate < 1000)
            av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low."
                                         "It takes bits/s as argument, not kbits/s\n");
        ret = avcodec_parameters_from_context(ost->st->codecpar, ost->enc_ctx);
        if (ret < 0) {
            av_log(NULL, AV_LOG_FATAL,
                   "Error initializing the output stream codec context.\n");
            exit_program(1);
        }
        if (ost->enc_ctx->nb_coded_side_data) {
            int i;
            ost->st->side_data = av_realloc_array(NULL, ost->enc_ctx->nb_coded_side_data,
                                                  sizeof(*ost->st->side_data));
            if (!ost->st->side_data)
                return AVERROR(ENOMEM);
            for (i = 0; i < ost->enc_ctx->nb_coded_side_data; i++) {
                const AVPacketSideData *sd_src = &ost->enc_ctx->coded_side_data[i];
                AVPacketSideData *sd_dst = &ost->st->side_data[i];
                sd_dst->data = av_malloc(sd_src->size);
                if (!sd_dst->data)
                    return AVERROR(ENOMEM);
                memcpy(sd_dst->data, sd_src->data, sd_src->size);
                sd_dst->size = sd_src->size;
                sd_dst->type = sd_src->type;
                ost->st->nb_side_data++;
            }
        }
        ost->st->time_base = ost->enc_ctx->time_base;
    } else if (ost->stream_copy) {
        ret = init_output_stream_streamcopy(ost);
        if (ret < 0)
            return ret;
        ret = avcodec_parameters_to_context(ost->parser_avctx, ost->st->codecpar);
        if (ret < 0)
            return ret;
    }
    ret = init_output_bsfs(ost);
    if (ret < 0)
        return ret;
    ost->mux_timebase = ost->st->time_base;
    ost->initialized = 1;
    ret = check_init_output_file(output_files[ost->file_index], ost->file_index);
    if (ret < 0)
        return ret;
    return ret;
}
['static int transcode_init(void)\n{\n    int ret = 0, i, j, k;\n    OutputStream *ost;\n    InputStream *ist;\n    char error[1024];\n    for (i = 0; i < nb_input_files; i++) {\n        InputFile *ifile = input_files[i];\n        if (ifile->rate_emu)\n            for (j = 0; j < ifile->nb_streams; j++)\n                input_streams[j + ifile->ist_index]->start = av_gettime_relative();\n    }\n    for (i = 0; i < nb_input_streams; i++)\n        if ((ret = init_input_stream(i, error, sizeof(error))) < 0)\n            goto dump_format;\n    for (i = 0; i < nb_output_streams; i++) {\n        if (output_streams[i]->filter)\n            continue;\n        ret = init_output_stream(output_streams[i], error, sizeof(error));\n        if (ret < 0)\n            goto dump_format;\n    }\n    for (i = 0; i < nb_input_files; i++) {\n        InputFile *ifile = input_files[i];\n        for (j = 0; j < ifile->ctx->nb_programs; j++) {\n            AVProgram *p = ifile->ctx->programs[j];\n            int discard  = AVDISCARD_ALL;\n            for (k = 0; k < p->nb_stream_indexes; k++)\n                if (!input_streams[ifile->ist_index + p->stream_index[k]]->discard) {\n                    discard = AVDISCARD_DEFAULT;\n                    break;\n                }\n            p->discard = discard;\n        }\n    }\n dump_format:\n    av_log(NULL, AV_LOG_INFO, "Stream mapping:\\n");\n    for (i = 0; i < nb_input_streams; i++) {\n        ist = input_streams[i];\n        for (j = 0; j < ist->nb_filters; j++) {\n            if (!filtergraph_is_simple(ist->filters[j]->graph)) {\n                av_log(NULL, AV_LOG_INFO, "  Stream #%d:%d (%s) -> %s",\n                       ist->file_index, ist->st->index, ist->dec ? ist->dec->name : "?",\n                       ist->filters[j]->name);\n                if (nb_filtergraphs > 1)\n                    av_log(NULL, AV_LOG_INFO, " (graph %d)", ist->filters[j]->graph->index);\n                av_log(NULL, AV_LOG_INFO, "\\n");\n            }\n        }\n    }\n    for (i = 0; i < nb_output_streams; i++) {\n        ost = output_streams[i];\n        if (ost->attachment_filename) {\n            av_log(NULL, AV_LOG_INFO, "  File %s -> Stream #%d:%d\\n",\n                   ost->attachment_filename, ost->file_index, ost->index);\n            continue;\n        }\n        if (ost->filter && !filtergraph_is_simple(ost->filter->graph)) {\n            av_log(NULL, AV_LOG_INFO, "  %s", ost->filter->name);\n            if (nb_filtergraphs > 1)\n                av_log(NULL, AV_LOG_INFO, " (graph %d)", ost->filter->graph->index);\n            av_log(NULL, AV_LOG_INFO, " -> Stream #%d:%d (%s)\\n", ost->file_index,\n                   ost->index, ost->enc ? ost->enc->name : "?");\n            continue;\n        }\n        av_log(NULL, AV_LOG_INFO, "  Stream #%d:%d -> #%d:%d",\n               input_streams[ost->source_index]->file_index,\n               input_streams[ost->source_index]->st->index,\n               ost->file_index,\n               ost->index);\n        if (ost->sync_ist != input_streams[ost->source_index])\n            av_log(NULL, AV_LOG_INFO, " [sync #%d:%d]",\n                   ost->sync_ist->file_index,\n                   ost->sync_ist->st->index);\n        if (ost->stream_copy)\n            av_log(NULL, AV_LOG_INFO, " (copy)");\n        else {\n            const AVCodec *in_codec    = input_streams[ost->source_index]->dec;\n            const AVCodec *out_codec   = ost->enc;\n            const char *decoder_name   = "?";\n            const char *in_codec_name  = "?";\n            const char *encoder_name   = "?";\n            const char *out_codec_name = "?";\n            const AVCodecDescriptor *desc;\n            if (in_codec) {\n                decoder_name  = in_codec->name;\n                desc = avcodec_descriptor_get(in_codec->id);\n                if (desc)\n                    in_codec_name = desc->name;\n                if (!strcmp(decoder_name, in_codec_name))\n                    decoder_name = "native";\n            }\n            if (out_codec) {\n                encoder_name   = out_codec->name;\n                desc = avcodec_descriptor_get(out_codec->id);\n                if (desc)\n                    out_codec_name = desc->name;\n                if (!strcmp(encoder_name, out_codec_name))\n                    encoder_name = "native";\n            }\n            av_log(NULL, AV_LOG_INFO, " (%s (%s) -> %s (%s))",\n                   in_codec_name, decoder_name,\n                   out_codec_name, encoder_name);\n        }\n        av_log(NULL, AV_LOG_INFO, "\\n");\n    }\n    if (ret) {\n        av_log(NULL, AV_LOG_ERROR, "%s\\n", error);\n        return ret;\n    }\n    return 0;\n}', 'int64_t av_gettime_relative(void)\n{\n#if HAVE_CLOCK_GETTIME\n    struct timespec ts;\n    clock_gettime(CLOCK_MONOTONIC, &ts);\n    return (int64_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000;\n#else\n    return av_gettime() + 42 * 60 * 60 * INT64_C(1000000);\n#endif\n}', 'static int init_output_stream(OutputStream *ost, char *error, int error_len)\n{\n    int ret = 0;\n    if (ost->encoding_needed) {\n        AVCodec      *codec = ost->enc;\n        AVCodecContext *dec = NULL;\n        InputStream *ist;\n        ret = init_output_stream_encode(ost);\n        if (ret < 0)\n            return ret;\n        if ((ist = get_input_stream(ost)))\n            dec = ist->dec_ctx;\n        if (dec && dec->subtitle_header) {\n            ost->enc_ctx->subtitle_header = av_malloc(dec->subtitle_header_size);\n            if (!ost->enc_ctx->subtitle_header)\n                return AVERROR(ENOMEM);\n            memcpy(ost->enc_ctx->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);\n            ost->enc_ctx->subtitle_header_size = dec->subtitle_header_size;\n        }\n        if (!av_dict_get(ost->encoder_opts, "threads", NULL, 0))\n            av_dict_set(&ost->encoder_opts, "threads", "auto", 0);\n        if (ost->filter && ost->filter->filter->inputs[0]->hw_frames_ctx) {\n            ost->enc_ctx->hw_frames_ctx = av_buffer_ref(ost->filter->filter->inputs[0]->hw_frames_ctx);\n            if (!ost->enc_ctx->hw_frames_ctx)\n                return AVERROR(ENOMEM);\n        }\n        if ((ret = avcodec_open2(ost->enc_ctx, codec, &ost->encoder_opts)) < 0) {\n            if (ret == AVERROR_EXPERIMENTAL)\n                abort_codec_experimental(codec, 1);\n            snprintf(error, error_len,\n                     "Error while opening encoder for output stream #%d:%d - "\n                     "maybe incorrect parameters such as bit_rate, rate, width or height",\n                    ost->file_index, ost->index);\n            return ret;\n        }\n        assert_avoptions(ost->encoder_opts);\n        if (ost->enc_ctx->bit_rate && ost->enc_ctx->bit_rate < 1000)\n            av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low."\n                                         "It takes bits/s as argument, not kbits/s\\n");\n        ret = avcodec_parameters_from_context(ost->st->codecpar, ost->enc_ctx);\n        if (ret < 0) {\n            av_log(NULL, AV_LOG_FATAL,\n                   "Error initializing the output stream codec context.\\n");\n            exit_program(1);\n        }\n        if (ost->enc_ctx->nb_coded_side_data) {\n            int i;\n            ost->st->side_data = av_realloc_array(NULL, ost->enc_ctx->nb_coded_side_data,\n                                                  sizeof(*ost->st->side_data));\n            if (!ost->st->side_data)\n                return AVERROR(ENOMEM);\n            for (i = 0; i < ost->enc_ctx->nb_coded_side_data; i++) {\n                const AVPacketSideData *sd_src = &ost->enc_ctx->coded_side_data[i];\n                AVPacketSideData *sd_dst = &ost->st->side_data[i];\n                sd_dst->data = av_malloc(sd_src->size);\n                if (!sd_dst->data)\n                    return AVERROR(ENOMEM);\n                memcpy(sd_dst->data, sd_src->data, sd_src->size);\n                sd_dst->size = sd_src->size;\n                sd_dst->type = sd_src->type;\n                ost->st->nb_side_data++;\n            }\n        }\n        ost->st->time_base = ost->enc_ctx->time_base;\n    } else if (ost->stream_copy) {\n        ret = init_output_stream_streamcopy(ost);\n        if (ret < 0)\n            return ret;\n        ret = avcodec_parameters_to_context(ost->parser_avctx, ost->st->codecpar);\n        if (ret < 0)\n            return ret;\n    }\n    ret = init_output_bsfs(ost);\n    if (ret < 0)\n        return ret;\n    ost->mux_timebase = ost->st->time_base;\n    ost->initialized = 1;\n    ret = check_init_output_file(output_files[ost->file_index], ost->file_index);\n    if (ret < 0)\n        return ret;\n    return ret;\n}', 'void *av_realloc_array(void *ptr, size_t nmemb, size_t size)\n{\n    if (!size || nmemb >= INT_MAX / size)\n        return NULL;\n    return av_realloc(ptr, nmemb * size);\n}']