ffmpeg.c:3617: error: Null Dereference
  pointer `st` last assigned on line 3611 could be null and is dereferenced at line 3617, column 20.

ffmpeg.c:3603:1: start of procedure new_subtitle_stream()
3601. }
3602. 
3603. static void new_subtitle_stream(AVFormatContext *oc, int file_idx)
      ^
3604. {
3605.     AVStream *st;

ffmpeg.c:3607:5: 
3605.     AVStream *st;
3606.     AVOutputStream *ost;
3607.     AVCodec *codec=NULL;
          ^
3608.     AVCodecContext *subtitle_enc;
3609.     enum CodecID codec_id = CODEC_ID_NONE;

ffmpeg.c:3609:5: 
3607.     AVCodec *codec=NULL;
3608.     AVCodecContext *subtitle_enc;
3609.     enum CodecID codec_id = CODEC_ID_NONE;
          ^
3610. 
3611.     st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);

ffmpeg.c:3611:28: Condition is true
3609.     enum CodecID codec_id = CODEC_ID_NONE;
3610. 
3611.     st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);
                                 ^
3612.     if (!st) {
3613.         fprintf(stderr, "Could not alloc stream\n");

ffmpeg.c:3611:5: 
3609.     enum CodecID codec_id = CODEC_ID_NONE;
3610. 
3611.     st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);
          ^
3612.     if (!st) {
3613.         fprintf(stderr, "Could not alloc stream\n");

libavformat/utils.c:2616:1: start of procedure av_new_stream()
  2614. }
  2615. 
  2616. AVStream *av_new_stream(AVFormatContext *s, int id)
        ^
  2617. {
  2618.     AVStream *st;

libavformat/utils.c:2622:9: Taking true branch
  2620. 
  2621. #if FF_API_MAX_STREAMS
  2622.     if (s->nb_streams >= MAX_STREAMS){
                ^
  2623.         av_log(s, AV_LOG_ERROR, "Too many streams\n");
  2624.         return NULL;

libavformat/utils.c:2623:9: Skipping av_log(): empty list of specs
  2621. #if FF_API_MAX_STREAMS
  2622.     if (s->nb_streams >= MAX_STREAMS){
  2623.         av_log(s, AV_LOG_ERROR, "Too many streams\n");
                ^
  2624.         return NULL;
  2625.     }

libavformat/utils.c:2624:9: 
  2622.     if (s->nb_streams >= MAX_STREAMS){
  2623.         av_log(s, AV_LOG_ERROR, "Too many streams\n");
  2624.         return NULL;
                ^
  2625.     }
  2626. #else

libavformat/utils.c:2673:1: return from a call to av_new_stream
  2671.     s->streams[s->nb_streams++] = st;
  2672.     return st;
  2673. }
        ^
  2674. 
  2675. AVProgram *av_new_program(AVFormatContext *ac, int id)

ffmpeg.c:3612:10: Taking true branch
3610. 
3611.     st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);
3612.     if (!st) {
               ^
3613.         fprintf(stderr, "Could not alloc stream\n");
3614.         ffmpeg_exit(1);

ffmpeg.c:3613:9: 
3611.     st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);
3612.     if (!st) {
3613.         fprintf(stderr, "Could not alloc stream\n");
              ^
3614.         ffmpeg_exit(1);
3615.     }

ffmpeg.c:3614:9: Skipping ffmpeg_exit(): empty list of specs
3612.     if (!st) {
3613.         fprintf(stderr, "Could not alloc stream\n");
3614.         ffmpeg_exit(1);
              ^
3615.     }
3616.     ost = new_output_stream(oc, file_idx);

ffmpeg.c:3616:5: Skipping new_output_stream(): empty list of specs
3614.         ffmpeg_exit(1);
3615.     }
3616.     ost = new_output_stream(oc, file_idx);
          ^
3617.     subtitle_enc = st->codec;
3618.     output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output_codecs, nb_output_codecs + 1);

ffmpeg.c:3617:5: 
3615.     }
3616.     ost = new_output_stream(oc, file_idx);
3617.     subtitle_enc = st->codec;
          ^
3618.     output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output_codecs, nb_output_codecs + 1);
3619.     if(!subtitle_stream_copy){

static void new_subtitle_stream(AVFormatContext *oc, int file_idx)
{
    AVStream *st;
    AVOutputStream *ost;
    AVCodec *codec=NULL;
    AVCodecContext *subtitle_enc;
    enum CodecID codec_id = CODEC_ID_NONE;
    st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);
    if (!st) {
        fprintf(stderr, "Could not alloc stream\n");
        ffmpeg_exit(1);
    }
    ost = new_output_stream(oc, file_idx);
    subtitle_enc = st->codec;
    output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output_codecs, nb_output_codecs + 1);
    if(!subtitle_stream_copy){
        if (subtitle_codec_name) {
            codec_id = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 1,
                                         avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->strict_std_compliance);
            codec= output_codecs[nb_output_codecs-1] = avcodec_find_encoder_by_name(subtitle_codec_name);
        } else {
            codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_SUBTITLE);
            codec = avcodec_find_encoder(codec_id);
        }
    }
    avcodec_get_context_defaults3(st->codec, codec);
    ost->bitstream_filters = subtitle_bitstream_filters;
    subtitle_bitstream_filters= NULL;
    subtitle_enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
    if(subtitle_codec_tag)
        subtitle_enc->codec_tag= subtitle_codec_tag;
    if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
        subtitle_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;
        avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->flags |= CODEC_FLAG_GLOBAL_HEADER;
    }
    if (subtitle_stream_copy) {
        st->stream_copy = 1;
    } else {
        subtitle_enc->codec_id = codec_id;
        set_context_opts(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], subtitle_enc, AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec);
    }
    if (subtitle_language) {
        av_metadata_set2(&st->metadata, "language", subtitle_language, 0);
        av_freep(&subtitle_language);
    }
    subtitle_disable = 0;
    av_freep(&subtitle_codec_name);
    subtitle_stream_copy = 0;
}
['static void new_subtitle_stream(AVFormatContext *oc, int file_idx)\n{\n    AVStream *st;\n    AVOutputStream *ost;\n    AVCodec *codec=NULL;\n    AVCodecContext *subtitle_enc;\n    enum CodecID codec_id = CODEC_ID_NONE;\n    st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);\n    if (!st) {\n        fprintf(stderr, "Could not alloc stream\\n");\n        ffmpeg_exit(1);\n    }\n    ost = new_output_stream(oc, file_idx);\n    subtitle_enc = st->codec;\n    output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output_codecs, nb_output_codecs + 1);\n    if(!subtitle_stream_copy){\n        if (subtitle_codec_name) {\n            codec_id = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 1,\n                                         avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->strict_std_compliance);\n            codec= output_codecs[nb_output_codecs-1] = avcodec_find_encoder_by_name(subtitle_codec_name);\n        } else {\n            codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_SUBTITLE);\n            codec = avcodec_find_encoder(codec_id);\n        }\n    }\n    avcodec_get_context_defaults3(st->codec, codec);\n    ost->bitstream_filters = subtitle_bitstream_filters;\n    subtitle_bitstream_filters= NULL;\n    subtitle_enc->codec_type = AVMEDIA_TYPE_SUBTITLE;\n    if(subtitle_codec_tag)\n        subtitle_enc->codec_tag= subtitle_codec_tag;\n    if (oc->oformat->flags & AVFMT_GLOBALHEADER) {\n        subtitle_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;\n        avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->flags |= CODEC_FLAG_GLOBAL_HEADER;\n    }\n    if (subtitle_stream_copy) {\n        st->stream_copy = 1;\n    } else {\n        subtitle_enc->codec_id = codec_id;\n        set_context_opts(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], subtitle_enc, AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec);\n    }\n    if (subtitle_language) {\n        av_metadata_set2(&st->metadata, "language", subtitle_language, 0);\n        av_freep(&subtitle_language);\n    }\n    subtitle_disable = 0;\n    av_freep(&subtitle_codec_name);\n    subtitle_stream_copy = 0;\n}', 'AVStream *av_new_stream(AVFormatContext *s, int id)\n{\n    AVStream *st;\n    int i;\n#if FF_API_MAX_STREAMS\n    if (s->nb_streams >= MAX_STREAMS){\n        av_log(s, AV_LOG_ERROR, "Too many streams\\n");\n        return NULL;\n    }\n#else\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#endif\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_context();\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}']