avconv.c:3412: error: Null Dereference
  pointer `st` last assigned on line 3398 could be null and is dereferenced at line 3412, column 9.

avconv.c:3395:1: start of procedure new_output_stream()
3393. }
3394. 
3395. static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)
      ^
3396. {
3397.     OutputStream *ost;

avconv.c:3398:5: 
3396. {
3397.     OutputStream *ost;
3398.     AVStream *st = avformat_new_stream(oc, NULL);
          ^
3399.     int idx      = oc->nb_streams - 1, ret = 0;
3400.     char *bsf = NULL, *next, *codec_tag = NULL;

libavformat/utils.c:2735:1: start of procedure avformat_new_stream()
  2733. #endif
  2734. 
  2735. AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c)
        ^
  2736. {
  2737.     AVStream *st;

libavformat/utils.c:2741:9: Taking true branch
  2739.     AVStream **streams;
  2740. 
  2741.     if (s->nb_streams >= INT_MAX/sizeof(*streams))
                ^
  2742.         return NULL;
  2743.     streams = av_realloc(s->streams, (s->nb_streams + 1) * sizeof(*streams));

libavformat/utils.c:2742:9: 
  2740. 
  2741.     if (s->nb_streams >= INT_MAX/sizeof(*streams))
  2742.         return NULL;
                ^
  2743.     streams = av_realloc(s->streams, (s->nb_streams + 1) * sizeof(*streams));
  2744.     if (!streams)

libavformat/utils.c:2783:1: return from a call to avformat_new_stream
  2781.     s->streams[s->nb_streams++] = st;
  2782.     return st;
  2783. }
        ^
  2784. 
  2785. AVProgram *av_new_program(AVFormatContext *ac, int id)

avconv.c:3399:5: 
3397.     OutputStream *ost;
3398.     AVStream *st = avformat_new_stream(oc, NULL);
3399.     int idx      = oc->nb_streams - 1, ret = 0;
          ^
3400.     char *bsf = NULL, *next, *codec_tag = NULL;
3401.     AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;

avconv.c:3400:5: 
3398.     AVStream *st = avformat_new_stream(oc, NULL);
3399.     int idx      = oc->nb_streams - 1, ret = 0;
3400.     char *bsf = NULL, *next, *codec_tag = NULL;
          ^
3401.     AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;
3402.     double qscale = -1;

avconv.c:3401:5: 
3399.     int idx      = oc->nb_streams - 1, ret = 0;
3400.     char *bsf = NULL, *next, *codec_tag = NULL;
3401.     AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;
          ^
3402.     double qscale = -1;
3403.     char *buf = NULL, *arg = NULL, *preset = NULL;

avconv.c:3402:5: 
3400.     char *bsf = NULL, *next, *codec_tag = NULL;
3401.     AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;
3402.     double qscale = -1;
          ^
3403.     char *buf = NULL, *arg = NULL, *preset = NULL;
3404.     AVIOContext *s = NULL;

avconv.c:3403:5: 
3401.     AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;
3402.     double qscale = -1;
3403.     char *buf = NULL, *arg = NULL, *preset = NULL;
          ^
3404.     AVIOContext *s = NULL;
3405. 

avconv.c:3404:5: 
3402.     double qscale = -1;
3403.     char *buf = NULL, *arg = NULL, *preset = NULL;
3404.     AVIOContext *s = NULL;
          ^
3405. 
3406.     if (!st) {

avconv.c:3406:10: Taking true branch
3404.     AVIOContext *s = NULL;
3405. 
3406.     if (!st) {
               ^
3407.         av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n");
3408.         exit_program(1);

avconv.c:3407:9: Skipping av_log(): empty list of specs
3405. 
3406.     if (!st) {
3407.         av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n");
              ^
3408.         exit_program(1);
3409.     }

avconv.c:3408:9: Skipping exit_program(): empty list of specs
3406.     if (!st) {
3407.         av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n");
3408.         exit_program(1);
              ^
3409.     }
3410. 

avconv.c:3411:9: Taking true branch
3409.     }
3410. 
3411.     if (oc->nb_streams - 1 < o->nb_streamid_map)
              ^
3412.         st->id = o->streamid_map[oc->nb_streams - 1];
3413. 

avconv.c:3412:9: 
3410. 
3411.     if (oc->nb_streams - 1 < o->nb_streamid_map)
3412.         st->id = o->streamid_map[oc->nb_streams - 1];
              ^
3413. 
3414.     output_streams = grow_array(output_streams, sizeof(*output_streams), &nb_output_streams,

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;
    char *buf = NULL, *arg = NULL, *preset = NULL;
    AVIOContext *s = NULL;
    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];
    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;
    choose_encoder(o, oc, ost);
    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(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->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);
    }
    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);
        st->codec->codec_tag = tag;
    }
    MATCH_PER_STREAM_OPT(qscale, dbl, qscale, oc, st);
    if (qscale >= 0 || same_quant) {
        st->codec->flags |= CODEC_FLAG_QSCALE;
        st->codec->global_quality = FF_QP2LAMBDA * qscale;
    }
    if (oc->oformat->flags & AVFMT_GLOBALHEADER)
        st->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
    av_opt_get_int(sws_opts, "sws_flags", 0, &ost->sws_flags);
    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    char *buf = NULL, *arg = NULL, *preset = NULL;\n    AVIOContext *s = NULL;\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    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    choose_encoder(o, oc, ost);\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(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->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    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        st->codec->codec_tag = tag;\n    }\n    MATCH_PER_STREAM_OPT(qscale, dbl, qscale, oc, st);\n    if (qscale >= 0 || same_quant) {\n        st->codec->flags |= CODEC_FLAG_QSCALE;\n        st->codec->global_quality = FF_QP2LAMBDA * qscale;\n    }\n    if (oc->oformat->flags & AVFMT_GLOBALHEADER)\n        st->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;\n    av_opt_get_int(sws_opts, "sws_flags", 0, &ost->sws_flags);\n    return ost;\n}', 'AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c)\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(c);\n    if (s->iformat) {\n        st->codec->bit_rate = 0;\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    avpriv_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}']