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

avconv_opt.c:881:1: <LHS trace>
879. }
880. 
881. static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)
     ^
882. {
883.     OutputStream *ost;

avconv_opt.c:881:1: Parameter `oc->nb_streams`
879. }
880. 
881. static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)
     ^
882. {
883.     OutputStream *ost;

avconv_opt.c:884:20: Call
882. {
883.     OutputStream *ost;
884.     AVStream *st = avformat_new_stream(oc, NULL);
                        ^
885.     int idx      = oc->nb_streams - 1, ret = 0;
886.     char *bsf = NULL, *next, *codec_tag = NULL;

libavformat/utils.c:2644:1: Parameter `s->nb_streams`
  2642. }
  2643. 
  2644. AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
        ^
  2645. {
  2646.     AVStream *st;

avconv_opt.c:885:5: Binary operation: ([0, oc->nb_streams] - 1):unsigned32
883.     OutputStream *ost;
884.     AVStream *st = avformat_new_stream(oc, NULL);
885.     int idx      = oc->nb_streams - 1, ret = 0;
         ^
886.     char *bsf = NULL, *next, *codec_tag = NULL;
887.     AVBitStreamFilterContext *bsfc, *bsfc_prev = 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;
    char *bsf = NULL, *next, *codec_tag = NULL;
    AVBitStreamFilterContext *bsfc, *bsfc_prev = 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->codec->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, bsf, oc, st);
    while (bsf) {
        if (next = strchr(bsf, ','))
            *next++ = 0;
        if (!(bsfc = av_bitstream_filter_init(bsf))) {
            av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\n", bsf);
            exit_program(1);
        }
        if (bsfc_prev)
            bsfc_prev->next = bsfc;
        else
            ost->bitstream_filters = bsfc;
        bsfc_prev = bsfc;
        bsf       = next;
    }
    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 |= CODEC_FLAG_QSCALE;
        ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale;
    }
    if (oc->oformat->flags & AVFMT_GLOBALHEADER)
        ost->enc_ctx->flags |= 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    char *bsf = NULL, *next, *codec_tag = NULL;\n    AVBitStreamFilterContext *bsfc, *bsfc_prev = 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->codec->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, bsf, oc, st);\n    while (bsf) {\n        if (next = strchr(bsf, \',\'))\n            *next++ = 0;\n        if (!(bsfc = av_bitstream_filter_init(bsf))) {\n            av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\\n", bsf);\n            exit_program(1);\n        }\n        if (bsfc_prev)\n            bsfc_prev->next = bsfc;\n        else\n            ost->bitstream_filters = bsfc;\n        bsfc_prev = bsfc;\n        bsf       = next;\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 |= 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 |= 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    st->codec = avcodec_alloc_context3(c);\n    if (s->iformat) {\n        st->codec->bit_rate = 0;\n        avpriv_set_pts_info(st, 33, 1, 90000);\n    }\n    st->index      = s->nb_streams;\n    st->start_time = AV_NOPTS_VALUE;\n    st->duration   = AV_NOPTS_VALUE;\n    st->cur_dts       = 0;\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    s->streams[s->nb_streams++] = st;\n    return st;\n}']