avconv.c:3476: error: Integer Overflow L2
  ([0, +oo] - 1):unsigned32 by call to `new_video_stream`.

avconv.c:3446:10: Unknown value from: strcmp
3444.     av_strlcpy(oc->filename, filename, sizeof(oc->filename));
3445. 
3446.     if (!strcmp(file_oformat->name, "ffm") &&
               ^
3447.         av_strstart(filename, "http:", NULL)) {
3448.         /* special case for files sent to avserver: we get the stream

avconv.c:3476:13: Call
3474.                 }
3475.             }
3476.             NEW_STREAM(video, idx);
                  ^
3477.         }
3478. 

avconv.c:3113:1: Parameter `oc->nb_streams`
  3111. }
  3112. 
  3113. static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc)
        ^
  3114. {
  3115.     AVStream *st;

avconv.c:3119:11: Call
  3117.     AVCodecContext *video_enc;
  3118. 
  3119.     ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO);
                  ^
  3120.     st  = ost->st;
  3121.     if (!st->stream_copy) {

avconv.c:3060:1: <LHS trace>
3058. }
3059. 
3060. static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)
      ^
3061. {
3062.     OutputStream *ost;

avconv.c:3060:1: Global `nb_streamid_map`
    3058. }
    3059. 
    3060. static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)
          ^
    3061. {
    3062.     OutputStream *ost;

avconv.c:3063:20: Call
    3061. {
    3062.     OutputStream *ost;
    3063.     AVStream *st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);
                             ^
    3064.     int idx      = oc->nb_streams - 1;
    3065.     int64_t max_frames = INT64_MAX;

libavformat/utils.c:2658:1: Parameter `s->nb_streams`
      2656. }
      2657. 
      2658. AVStream *av_new_stream(AVFormatContext *s, int id)
            ^
      2659. {
      2660.     AVStream *st;

avconv.c:3064:5: Binary operation: ([0, +oo] - 1):unsigned32 by call to `new_video_stream` 
    3062.     OutputStream *ost;
    3063.     AVStream *st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);
    3064.     int idx      = oc->nb_streams - 1;
              ^
    3065.     int64_t max_frames = INT64_MAX;
    3066.     char *bsf = NULL, *next;

static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)
{
    OutputStream *ost;
    AVStream *st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);
    int idx      = oc->nb_streams - 1;
    int64_t max_frames = INT64_MAX;
    char *bsf = NULL, *next;
    AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;
    if (!st) {
        av_log(NULL, AV_LOG_ERROR, "Could not alloc stream.\n");
        exit_program(1);
    }
    output_streams = grow_array(output_streams, sizeof(*output_streams), &nb_output_streams,
                                nb_output_streams + 1);
    ost = &output_streams[nb_output_streams - 1];
    ost->file_index = nb_output_files;
    ost->index = idx;
    ost->st    = st;
    st->codec->codec_type = type;
    ost->enc = choose_codec(o, oc, st, type);
    if (ost->enc) {
        ost->opts  = filter_codec_opts(codec_opts, ost->enc->id, oc, st);
    }
    avcodec_get_context_defaults3(st->codec, ost->enc);
    st->codec->codec_type = type;
    MATCH_PER_STREAM_OPT(max_frames, i64, max_frames, oc, st);
    ost->max_frames = max_frames;
    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_ERROR, "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;
    }
    ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
    return ost;
}
['static void opt_output_file(void *optctx, const char *filename)\n{\n    OptionsContext *o = optctx;\n    AVFormatContext *oc;\n    int i, err;\n    AVOutputFormat *file_oformat;\n    OutputStream *ost;\n    InputStream  *ist;\n    if (!strcmp(filename, "-"))\n        filename = "pipe:";\n    oc = avformat_alloc_context();\n    if (!oc) {\n        print_error(filename, AVERROR(ENOMEM));\n        exit_program(1);\n    }\n    if (o->format) {\n        file_oformat = av_guess_format(o->format, NULL, NULL);\n        if (!file_oformat) {\n            fprintf(stderr, "Requested output format \'%s\' is not a suitable output format\\n", o->format);\n            exit_program(1);\n        }\n    } else {\n        file_oformat = av_guess_format(NULL, filename, NULL);\n        if (!file_oformat) {\n            fprintf(stderr, "Unable to find a suitable output format for \'%s\'\\n",\n                    filename);\n            exit_program(1);\n        }\n    }\n    oc->oformat = file_oformat;\n    av_strlcpy(oc->filename, filename, sizeof(oc->filename));\n    if (!strcmp(file_oformat->name, "ffm") &&\n        av_strstart(filename, "http:", NULL)) {\n        int err = read_avserver_streams(o, oc, filename);\n        if (err < 0) {\n            print_error(filename, err);\n            exit_program(1);\n        }\n    } else if (!o->nb_stream_maps) {\n#define NEW_STREAM(type, index)\\\n        if (index >= 0) {\\\n            ost = new_ ## type ## _stream(o, oc);\\\n            ost->source_index = index;\\\n            ost->sync_ist     = &input_streams[index];\\\n            input_streams[index].discard = 0;\\\n        }\n        if (!video_disable && oc->oformat->video_codec != CODEC_ID_NONE) {\n            int area = 0, idx = -1;\n            for (i = 0; i < nb_input_streams; i++) {\n                ist = &input_streams[i];\n                if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&\n                    ist->st->codec->width * ist->st->codec->height > area) {\n                    area = ist->st->codec->width * ist->st->codec->height;\n                    idx = i;\n                }\n            }\n            NEW_STREAM(video, idx);\n        }\n        if (!audio_disable && oc->oformat->audio_codec != CODEC_ID_NONE) {\n            int channels = 0, idx = -1;\n            for (i = 0; i < nb_input_streams; i++) {\n                ist = &input_streams[i];\n                if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&\n                    ist->st->codec->channels > channels) {\n                    channels = ist->st->codec->channels;\n                    idx = i;\n                }\n            }\n            NEW_STREAM(audio, idx);\n        }\n        if (!subtitle_disable && oc->oformat->subtitle_codec != CODEC_ID_NONE) {\n            for (i = 0; i < nb_input_streams; i++)\n                if (input_streams[i].st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {\n                    NEW_STREAM(subtitle, i);\n                    break;\n                }\n        }\n    } else {\n        for (i = 0; i < o->nb_stream_maps; i++) {\n            StreamMap *map = &o->stream_maps[i];\n            if (map->disabled)\n                continue;\n            ist = &input_streams[input_files[map->file_index].ist_index + map->stream_index];\n            switch (ist->st->codec->codec_type) {\n            case AVMEDIA_TYPE_VIDEO:    ost = new_video_stream(o, oc);    break;\n            case AVMEDIA_TYPE_AUDIO:    ost = new_audio_stream(o, oc);    break;\n            case AVMEDIA_TYPE_SUBTITLE: ost = new_subtitle_stream(o, oc); break;\n            case AVMEDIA_TYPE_DATA:     ost = new_data_stream(o, oc);     break;\n            default:\n                av_log(NULL, AV_LOG_ERROR, "Cannot map stream #%d.%d - unsupported type.\\n",\n                       map->file_index, map->stream_index);\n                exit_program(1);\n            }\n            ost->source_index = input_files[map->file_index].ist_index + map->stream_index;\n            ost->sync_ist = &input_streams[input_files[map->sync_file_index].ist_index +\n                                           map->sync_stream_index];\n            ist->discard = 0;\n        }\n    }\n    output_files = grow_array(output_files, sizeof(*output_files), &nb_output_files, nb_output_files + 1);\n    output_files[nb_output_files - 1].ctx       = oc;\n    output_files[nb_output_files - 1].ost_index = nb_output_streams - oc->nb_streams;\n    output_files[nb_output_files - 1].recording_time = o->recording_time;\n    output_files[nb_output_files - 1].start_time     = o->start_time;\n    output_files[nb_output_files - 1].limit_filesize = o->limit_filesize;\n    av_dict_copy(&output_files[nb_output_files - 1].opts, format_opts, 0);\n    if (oc->oformat->flags & AVFMT_NEEDNUMBER) {\n        if (!av_filename_number_test(oc->filename)) {\n            print_error(oc->filename, AVERROR(EINVAL));\n            exit_program(1);\n        }\n    }\n    if (!(oc->oformat->flags & AVFMT_NOFILE)) {\n        if (!file_overwrite &&\n            (strchr(filename, \':\') == NULL ||\n             filename[1] == \':\' ||\n             av_strstart(filename, "file:", NULL))) {\n            if (avio_check(filename, 0) == 0) {\n                if (!using_stdin) {\n                    fprintf(stderr,"File \'%s\' already exists. Overwrite ? [y/N] ", filename);\n                    fflush(stderr);\n                    if (!read_yesno()) {\n                        fprintf(stderr, "Not overwriting - exiting\\n");\n                        exit_program(1);\n                    }\n                }\n                else {\n                    fprintf(stderr,"File \'%s\' already exists. Exiting.\\n", filename);\n                    exit_program(1);\n                }\n            }\n        }\n        if ((err = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE)) < 0) {\n            print_error(filename, err);\n            exit_program(1);\n        }\n    }\n    oc->preload   = (int)(o->mux_preload   * AV_TIME_BASE);\n    oc->max_delay = (int)(o->mux_max_delay * AV_TIME_BASE);\n    oc->flags |= AVFMT_FLAG_NONBLOCK;\n    if (o->chapters_input_file >= nb_input_files) {\n        if (o->chapters_input_file == INT_MAX) {\n            o->chapters_input_file = -1;\n            for (i = 0; i < nb_input_files; i++)\n                if (input_files[i].ctx->nb_chapters) {\n                    o->chapters_input_file = i;\n                    break;\n                }\n        } else {\n            av_log(NULL, AV_LOG_ERROR, "Invalid input file index %d in chapter mapping.\\n",\n                   o->chapters_input_file);\n            exit_program(1);\n        }\n    }\n    if (o->chapters_input_file >= 0)\n        copy_chapters(&input_files[o->chapters_input_file], &output_files[nb_output_files - 1],\n                      o->metadata_chapters_manual);\n    for (i = 0; i < o->nb_meta_data_maps; i++) {\n        AVFormatContext *files[2];\n        AVDictionary    **meta[2];\n        int j;\n#define METADATA_CHECK_INDEX(index, nb_elems, desc)\\\n        if ((index) < 0 || (index) >= (nb_elems)) {\\\n            av_log(NULL, AV_LOG_ERROR, "Invalid %s index %d while processing metadata maps\\n",\\\n                     (desc), (index));\\\n            exit_program(1);\\\n        }\n        int in_file_index = o->meta_data_maps[i][1].file;\n        if (in_file_index < 0)\n            continue;\n        METADATA_CHECK_INDEX(in_file_index, nb_input_files, "input file")\n        files[0] = oc;\n        files[1] = input_files[in_file_index].ctx;\n        for (j = 0; j < 2; j++) {\n            MetadataMap *map = &o->meta_data_maps[i][j];\n            switch (map->type) {\n            case \'g\':\n                meta[j] = &files[j]->metadata;\n                break;\n            case \'s\':\n                METADATA_CHECK_INDEX(map->index, files[j]->nb_streams, "stream")\n                meta[j] = &files[j]->streams[map->index]->metadata;\n                break;\n            case \'c\':\n                METADATA_CHECK_INDEX(map->index, files[j]->nb_chapters, "chapter")\n                meta[j] = &files[j]->chapters[map->index]->metadata;\n                break;\n            case \'p\':\n                METADATA_CHECK_INDEX(map->index, files[j]->nb_programs, "program")\n                meta[j] = &files[j]->programs[map->index]->metadata;\n                break;\n            }\n        }\n        av_dict_copy(meta[0], *meta[1], AV_DICT_DONT_OVERWRITE);\n    }\n    if (!o->metadata_global_manual && nb_input_files)\n        av_dict_copy(&oc->metadata, input_files[0].ctx->metadata,\n                     AV_DICT_DONT_OVERWRITE);\n    if (!o->metadata_streams_manual)\n        for (i = output_files[nb_output_files - 1].ost_index; i < nb_output_streams; i++) {\n            InputStream *ist = &input_streams[output_streams[i].source_index];\n            av_dict_copy(&output_streams[i].st->metadata, ist->st->metadata, AV_DICT_DONT_OVERWRITE);\n        }\n    for (i = 0; i < o->nb_metadata; i++) {\n        AVDictionary **m;\n        char type, *val;\n        int index = 0;\n        val = strchr(o->metadata[i].u.str, \'=\');\n        if (!val) {\n            av_log(NULL, AV_LOG_ERROR, "No \'=\' character in metadata string %s.\\n",\n                   o->metadata[i].u.str);\n            exit_program(1);\n        }\n        *val++ = 0;\n        parse_meta_type(o->metadata[i].specifier, &type, &index);\n        switch (type) {\n        case \'g\':\n            m = &oc->metadata;\n            break;\n        case \'s\':\n            if (index < 0 || index >= oc->nb_streams) {\n                av_log(NULL, AV_LOG_ERROR, "Invalid stream index %d in metadata specifier.\\n", index);\n                exit_program(1);\n            }\n            m = &oc->streams[i]->metadata;\n            break;\n        case \'c\':\n            if (index < 0 || index >= oc->nb_chapters) {\n                av_log(NULL, AV_LOG_ERROR, "Invalid chapter index %d in metadata specifier.\\n", index);\n                exit_program(1);\n            }\n            m = &oc->chapters[i]->metadata;\n            break;\n        default:\n            av_log(NULL, AV_LOG_ERROR, "Invalid metadata specifier %s.\\n", o->metadata[i].specifier);\n            exit_program(1);\n        }\n        av_dict_set(m, o->metadata[i].u.str, *val ? val : NULL, 0);\n    }\n    frame_rate    = (AVRational){0, 0};\n    frame_width   = 0;\n    frame_height  = 0;\n    audio_sample_rate = 0;\n    audio_channels    = 0;\n    audio_sample_fmt  = AV_SAMPLE_FMT_NONE;\n    av_freep(&streamid_map);\n    nb_streamid_map = 0;\n    av_freep(&forced_key_frames);\n    reset_options(o);\n}', 'static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc)\n{\n    AVStream *st;\n    OutputStream *ost;\n    AVCodecContext *video_enc;\n    ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO);\n    st  = ost->st;\n    if (!st->stream_copy) {\n        ost->frame_aspect_ratio = frame_aspect_ratio;\n        frame_aspect_ratio = 0;\n#if CONFIG_AVFILTER\n        ost->avfilter= vfilters;\n        vfilters = NULL;\n#endif\n    }\n    video_enc = st->codec;\n    if(video_codec_tag)\n        video_enc->codec_tag= video_codec_tag;\n    if(oc->oformat->flags & AVFMT_GLOBALHEADER) {\n        video_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;\n    }\n    if (st->stream_copy) {\n        video_enc->sample_aspect_ratio =\n        st->sample_aspect_ratio = av_d2q(frame_aspect_ratio*frame_height/frame_width, 255);\n    } else {\n        const char *p;\n        int i;\n        if (frame_rate.num)\n            ost->frame_rate = frame_rate;\n        video_enc->width = frame_width;\n        video_enc->height = frame_height;\n        video_enc->pix_fmt = frame_pix_fmt;\n        st->sample_aspect_ratio = video_enc->sample_aspect_ratio;\n        if (video_qscale || same_quant) {\n            video_enc->flags |= CODEC_FLAG_QSCALE;\n            video_enc->global_quality = FF_QP2LAMBDA * video_qscale;\n        }\n        if(intra_matrix)\n            video_enc->intra_matrix = intra_matrix;\n        if(inter_matrix)\n            video_enc->inter_matrix = inter_matrix;\n        p= video_rc_override_string;\n        for(i=0; p; i++){\n            int start, end, q;\n            int e=sscanf(p, "%d,%d,%d", &start, &end, &q);\n            if(e!=3){\n                fprintf(stderr, "error parsing rc_override\\n");\n                exit_program(1);\n            }\n            video_enc->rc_override=\n                av_realloc(video_enc->rc_override,\n                           sizeof(RcOverride)*(i+1));\n            video_enc->rc_override[i].start_frame= start;\n            video_enc->rc_override[i].end_frame  = end;\n            if(q>0){\n                video_enc->rc_override[i].qscale= q;\n                video_enc->rc_override[i].quality_factor= 1.0;\n            }\n            else{\n                video_enc->rc_override[i].qscale= 0;\n                video_enc->rc_override[i].quality_factor= -q/100.0;\n            }\n            p= strchr(p, \'/\');\n            if(p) p++;\n        }\n        video_enc->rc_override_count=i;\n        if (!video_enc->rc_initial_buffer_occupancy)\n            video_enc->rc_initial_buffer_occupancy = video_enc->rc_buffer_size*3/4;\n        video_enc->me_threshold= me_threshold;\n        video_enc->intra_dc_precision= intra_dc_precision - 8;\n        if (do_psnr)\n            video_enc->flags|= CODEC_FLAG_PSNR;\n        if (do_pass) {\n            if (do_pass == 1) {\n                video_enc->flags |= CODEC_FLAG_PASS1;\n            } else {\n                video_enc->flags |= CODEC_FLAG_PASS2;\n            }\n        }\n        if (forced_key_frames)\n            parse_forced_key_frames(forced_key_frames, ost, video_enc);\n    }\n    if (video_language) {\n        av_dict_set(&st->metadata, "language", video_language, 0);\n        av_freep(&video_language);\n    }\n    video_disable = 0;\n    av_freep(&forced_key_frames);\n    frame_pix_fmt = PIX_FMT_NONE;\n    return ost;\n}', 'static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)\n{\n    OutputStream *ost;\n    AVStream *st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);\n    int idx      = oc->nb_streams - 1;\n    int64_t max_frames = INT64_MAX;\n    char *bsf = NULL, *next;\n    AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;\n    if (!st) {\n        av_log(NULL, AV_LOG_ERROR, "Could not alloc stream.\\n");\n        exit_program(1);\n    }\n    output_streams = grow_array(output_streams, sizeof(*output_streams), &nb_output_streams,\n                                nb_output_streams + 1);\n    ost = &output_streams[nb_output_streams - 1];\n    ost->file_index = nb_output_files;\n    ost->index = idx;\n    ost->st    = st;\n    st->codec->codec_type = type;\n    ost->enc = choose_codec(o, oc, st, type);\n    if (ost->enc) {\n        ost->opts  = filter_codec_opts(codec_opts, ost->enc->id, oc, st);\n    }\n    avcodec_get_context_defaults3(st->codec, ost->enc);\n    st->codec->codec_type = type;\n    MATCH_PER_STREAM_OPT(max_frames, i64, max_frames, oc, st);\n    ost->max_frames = max_frames;\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_ERROR, "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    ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL);\n    return ost;\n}', 'AVStream *av_new_stream(AVFormatContext *s, int id)\n{\n    AVStream *st;\n    int i;\n    AVStream **streams;\n    if (s->nb_streams >= INT_MAX/sizeof(*streams))\n        return NULL;\n    streams = av_realloc(s->streams, (s->nb_streams + 1) * sizeof(*streams));\n    if (!streams)\n        return NULL;\n    s->streams = streams;\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(NULL);\n    if (s->iformat) {\n        st->codec->bit_rate = 0;\n    }\n    st->index = s->nb_streams;\n    st->id = id;\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    av_set_pts_info(st, 33, 1, 90000);\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->reference_dts = AV_NOPTS_VALUE;\n    st->sample_aspect_ratio = (AVRational){0,1};\n    s->streams[s->nb_streams++] = st;\n    return st;\n}']