avconv_opt.c:943: error: Integer Overflow L2
  ([0, `oc->nb_streams`] - 1):unsigned32.

avconv_opt.c:939:1: <LHS trace>
937. }
938. 
939. static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)
     ^
940. {
941.     OutputStream *ost;

avconv_opt.c:939:1: Parameter `oc->nb_streams`
937. }
938. 
939. static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)
     ^
940. {
941.     OutputStream *ost;

avconv_opt.c:942:20: Call
940. {
941.     OutputStream *ost;
942.     AVStream *st = avformat_new_stream(oc, NULL);
                        ^
943.     int idx      = oc->nb_streams - 1, ret = 0;
944.     const char *bsfs = NULL;

libavformat/utils.c:2652:1: Parameter `s->nb_streams`
  2650. }
  2651. 
  2652. AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
        ^
  2653. {
  2654.     AVStream *st;

avconv_opt.c:943:5: Binary operation: ([0, oc->nb_streams] - 1):unsigned32
941.     OutputStream *ost;
942.     AVStream *st = avformat_new_stream(oc, NULL);
943.     int idx      = oc->nb_streams - 1, ret = 0;
         ^
944.     const char *bsfs = NULL;
945.     char *next, *codec_tag = NULL;

static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)
{
    OutputStream *ost;
    AVStream *st = avformat_new_stream(oc, NULL);
    int idx      = oc->nb_streams - 1, ret = 0;
    const char *bsfs = NULL;
    char *next, *codec_tag = NULL;
    double qscale = -1;
    if (!st) {
        av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n");
        exit_program(1);
    }
    if (oc->nb_streams - 1 < o->nb_streamid_map)
        st->id = o->streamid_map[oc->nb_streams - 1];
    GROW_ARRAY(output_streams, nb_output_streams);
    if (!(ost = av_mallocz(sizeof(*ost))))
        exit_program(1);
    output_streams[nb_output_streams - 1] = ost;
    ost->file_index = nb_output_files - 1;
    ost->index      = idx;
    ost->st         = st;
    st->codecpar->codec_type = type;
    choose_encoder(o, oc, ost);
    ost->enc_ctx = avcodec_alloc_context3(ost->enc);
    if (!ost->enc_ctx) {
        av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding context.\n");
        exit_program(1);
    }
    ost->enc_ctx->codec_type = type;
    if (ost->enc) {
        AVIOContext *s = NULL;
        char *buf = NULL, *arg = NULL, *preset = NULL;
        ost->encoder_opts  = filter_codec_opts(o->g->codec_opts, ost->enc->id, oc, st, ost->enc);
        MATCH_PER_STREAM_OPT(presets, str, preset, oc, st);
        if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) {
            do  {
                buf = get_line(s);
                if (!buf[0] || buf[0] == '#') {
                    av_free(buf);
                    continue;
                }
                if (!(arg = strchr(buf, '='))) {
                    av_log(NULL, AV_LOG_FATAL, "Invalid line found in the preset file.\n");
                    exit_program(1);
                }
                *arg++ = 0;
                av_dict_set(&ost->encoder_opts, buf, arg, AV_DICT_DONT_OVERWRITE);
                av_free(buf);
            } while (!s->eof_reached);
            avio_close(s);
        }
        if (ret) {
            av_log(NULL, AV_LOG_FATAL,
                   "Preset %s specified for stream %d:%d, but could not be opened.\n",
                   preset, ost->file_index, ost->index);
            exit_program(1);
        }
    } else {
        ost->encoder_opts = filter_codec_opts(o->g->codec_opts, AV_CODEC_ID_NONE, oc, st, NULL);
    }
    ost->max_frames = INT64_MAX;
    MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st);
    MATCH_PER_STREAM_OPT(bitstream_filters, str, bsfs, oc, st);
    while (bsfs && *bsfs) {
        const AVBitStreamFilter *filter;
        char *bsf;
        bsf = av_get_token(&bsfs, ",");
        if (!bsf)
            exit_program(1);
        filter = av_bsf_get_by_name(bsf);
        if (!filter) {
            av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\n", bsf);
            exit_program(1);
        }
        av_freep(&bsf);
        ost->bitstream_filters = av_realloc_array(ost->bitstream_filters,
                                                  ost->nb_bitstream_filters + 1,
                                                  sizeof(*ost->bitstream_filters));
        if (!ost->bitstream_filters)
            exit_program(1);
        ost->bitstream_filters[ost->nb_bitstream_filters++] = filter;
        if (*bsfs)
            bsfs++;
    }
    MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, oc, st);
    if (codec_tag) {
        uint32_t tag = strtol(codec_tag, &next, 0);
        if (*next)
            tag = AV_RL32(codec_tag);
        ost->enc_ctx->codec_tag = tag;
    }
    MATCH_PER_STREAM_OPT(qscale, dbl, qscale, oc, st);
    if (qscale >= 0) {
        ost->enc_ctx->flags |= AV_CODEC_FLAG_QSCALE;
        ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale;
    }
    if (oc->oformat->flags & AVFMT_GLOBALHEADER)
        ost->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
    av_opt_get_int(o->g->sws_opts, "sws_flags", 0, &ost->sws_flags);
    av_dict_copy(&ost->resample_opts, o->g->resample_opts, 0);
    ost->pix_fmts[0] = ost->pix_fmts[1] = AV_PIX_FMT_NONE;
    ost->last_mux_dts = AV_NOPTS_VALUE;
    return ost;
}
['static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)\n{\n    OutputStream *ost;\n    AVStream *st = avformat_new_stream(oc, NULL);\n    int idx      = oc->nb_streams - 1, ret = 0;\n    const char *bsfs = NULL;\n    char *next, *codec_tag = NULL;\n    double qscale = -1;\n    if (!st) {\n        av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\\n");\n        exit_program(1);\n    }\n    if (oc->nb_streams - 1 < o->nb_streamid_map)\n        st->id = o->streamid_map[oc->nb_streams - 1];\n    GROW_ARRAY(output_streams, nb_output_streams);\n    if (!(ost = av_mallocz(sizeof(*ost))))\n        exit_program(1);\n    output_streams[nb_output_streams - 1] = ost;\n    ost->file_index = nb_output_files - 1;\n    ost->index      = idx;\n    ost->st         = st;\n    st->codecpar->codec_type = type;\n    choose_encoder(o, oc, ost);\n    ost->enc_ctx = avcodec_alloc_context3(ost->enc);\n    if (!ost->enc_ctx) {\n        av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding context.\\n");\n        exit_program(1);\n    }\n    ost->enc_ctx->codec_type = type;\n    if (ost->enc) {\n        AVIOContext *s = NULL;\n        char *buf = NULL, *arg = NULL, *preset = NULL;\n        ost->encoder_opts  = filter_codec_opts(o->g->codec_opts, ost->enc->id, oc, st, ost->enc);\n        MATCH_PER_STREAM_OPT(presets, str, preset, oc, st);\n        if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) {\n            do  {\n                buf = get_line(s);\n                if (!buf[0] || buf[0] == \'#\') {\n                    av_free(buf);\n                    continue;\n                }\n                if (!(arg = strchr(buf, \'=\'))) {\n                    av_log(NULL, AV_LOG_FATAL, "Invalid line found in the preset file.\\n");\n                    exit_program(1);\n                }\n                *arg++ = 0;\n                av_dict_set(&ost->encoder_opts, buf, arg, AV_DICT_DONT_OVERWRITE);\n                av_free(buf);\n            } while (!s->eof_reached);\n            avio_close(s);\n        }\n        if (ret) {\n            av_log(NULL, AV_LOG_FATAL,\n                   "Preset %s specified for stream %d:%d, but could not be opened.\\n",\n                   preset, ost->file_index, ost->index);\n            exit_program(1);\n        }\n    } else {\n        ost->encoder_opts = filter_codec_opts(o->g->codec_opts, AV_CODEC_ID_NONE, oc, st, NULL);\n    }\n    ost->max_frames = INT64_MAX;\n    MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st);\n    MATCH_PER_STREAM_OPT(bitstream_filters, str, bsfs, oc, st);\n    while (bsfs && *bsfs) {\n        const AVBitStreamFilter *filter;\n        char *bsf;\n        bsf = av_get_token(&bsfs, ",");\n        if (!bsf)\n            exit_program(1);\n        filter = av_bsf_get_by_name(bsf);\n        if (!filter) {\n            av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\\n", bsf);\n            exit_program(1);\n        }\n        av_freep(&bsf);\n        ost->bitstream_filters = av_realloc_array(ost->bitstream_filters,\n                                                  ost->nb_bitstream_filters + 1,\n                                                  sizeof(*ost->bitstream_filters));\n        if (!ost->bitstream_filters)\n            exit_program(1);\n        ost->bitstream_filters[ost->nb_bitstream_filters++] = filter;\n        if (*bsfs)\n            bsfs++;\n    }\n    MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, oc, st);\n    if (codec_tag) {\n        uint32_t tag = strtol(codec_tag, &next, 0);\n        if (*next)\n            tag = AV_RL32(codec_tag);\n        ost->enc_ctx->codec_tag = tag;\n    }\n    MATCH_PER_STREAM_OPT(qscale, dbl, qscale, oc, st);\n    if (qscale >= 0) {\n        ost->enc_ctx->flags |= AV_CODEC_FLAG_QSCALE;\n        ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale;\n    }\n    if (oc->oformat->flags & AVFMT_GLOBALHEADER)\n        ost->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;\n    av_opt_get_int(o->g->sws_opts, "sws_flags", 0, &ost->sws_flags);\n    av_dict_copy(&ost->resample_opts, o->g->resample_opts, 0);\n    ost->pix_fmts[0] = ost->pix_fmts[1] = AV_PIX_FMT_NONE;\n    ost->last_mux_dts = AV_NOPTS_VALUE;\n    return ost;\n}', 'AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)\n{\n    AVStream *st;\n    int i;\n    if (av_reallocp_array(&s->streams, s->nb_streams + 1,\n                          sizeof(*s->streams)) < 0) {\n        s->nb_streams = 0;\n        return NULL;\n    }\n    st = av_mallocz(sizeof(AVStream));\n    if (!st)\n        return NULL;\n    if (!(st->info = av_mallocz(sizeof(*st->info)))) {\n        av_free(st);\n        return NULL;\n    }\n#if FF_API_LAVF_AVCTX\nFF_DISABLE_DEPRECATION_WARNINGS\n    st->codec = avcodec_alloc_context3(c);\n    if (!st->codec) {\n        av_free(st->info);\n        av_free(st);\n        return NULL;\n    }\nFF_ENABLE_DEPRECATION_WARNINGS\n#endif\n    st->internal = av_mallocz(sizeof(*st->internal));\n    if (!st->internal)\n        goto fail;\n    if (s->iformat) {\n#if FF_API_LAVF_AVCTX\nFF_DISABLE_DEPRECATION_WARNINGS\n        st->codec->bit_rate = 0;\nFF_ENABLE_DEPRECATION_WARNINGS\n#endif\n        avpriv_set_pts_info(st, 33, 1, 90000);\n        st->cur_dts = 0;\n    } else {\n        st->cur_dts = AV_NOPTS_VALUE;\n    }\n    st->codecpar = avcodec_parameters_alloc();\n    if (!st->codecpar)\n        goto fail;\n    st->internal->avctx = avcodec_alloc_context3(NULL);\n    if (!st->internal->avctx)\n        goto fail;\n    st->index      = s->nb_streams;\n    st->start_time = AV_NOPTS_VALUE;\n    st->duration   = AV_NOPTS_VALUE;\n    st->first_dts     = AV_NOPTS_VALUE;\n    st->probe_packets = MAX_PROBE_PACKETS;\n    st->last_IP_pts = AV_NOPTS_VALUE;\n    for (i = 0; i < MAX_REORDER_DELAY + 1; i++)\n        st->pts_buffer[i] = AV_NOPTS_VALUE;\n    st->sample_aspect_ratio = (AVRational) { 0, 1 };\n    st->info->fps_first_dts = AV_NOPTS_VALUE;\n    st->info->fps_last_dts  = AV_NOPTS_VALUE;\n#if FF_API_LAVF_AVCTX\n    st->internal->need_codec_update = 1;\n#endif\n    s->streams[s->nb_streams++] = st;\n    return st;\nfail:\n    free_stream(&st);\n    return NULL;\n}']