ffmpeg.c:3574: error: Null Dereference
  pointer `st` last assigned on line 3555 could be null and is dereferenced at line 3574, column 35.

ffmpeg.c:3547:1: start of procedure new_audio_stream()
3545. }
3546. 
3547. static void new_audio_stream(AVFormatContext *oc, int file_idx)
      ^
3548. {
3549.     AVStream *st;

ffmpeg.c:3551:5: 
3549.     AVStream *st;
3550.     AVOutputStream *ost;
3551.     AVCodec *codec= NULL;
          ^
3552.     AVCodecContext *audio_enc;
3553.     enum CodecID codec_id = CODEC_ID_NONE;

ffmpeg.c:3553:5: 
3551.     AVCodec *codec= NULL;
3552.     AVCodecContext *audio_enc;
3553.     enum CodecID codec_id = CODEC_ID_NONE;
          ^
3554. 
3555.     st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);

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

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

libavformat/utils.c:2582:1: start of procedure av_new_stream()
  2580. }
  2581. 
  2582. AVStream *av_new_stream(AVFormatContext *s, int id)
        ^
  2583. {
  2584.     AVStream *st;

libavformat/utils.c:2588:9: Taking true branch
  2586.     AVStream **streams;
  2587. 
  2588.     if (s->nb_streams >= INT_MAX/sizeof(*streams))
                ^
  2589.         return NULL;
  2590.     streams = av_realloc(s->streams, (s->nb_streams + 1) * sizeof(*streams));

libavformat/utils.c:2589:9: 
  2587. 
  2588.     if (s->nb_streams >= INT_MAX/sizeof(*streams))
  2589.         return NULL;
                ^
  2590.     streams = av_realloc(s->streams, (s->nb_streams + 1) * sizeof(*streams));
  2591.     if (!streams)

libavformat/utils.c:2631:1: return from a call to av_new_stream
  2629.     s->streams[s->nb_streams++] = st;
  2630.     return st;
  2631. }
        ^
  2632. 
  2633. AVProgram *av_new_program(AVFormatContext *ac, int id)

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

ffmpeg.c:3557:9: 
3555.     st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);
3556.     if (!st) {
3557.         fprintf(stderr, "Could not alloc stream\n");
              ^
3558.         ffmpeg_exit(1);
3559.     }

ffmpeg.c:3558:9: Skipping ffmpeg_exit(): empty list of specs
3556.     if (!st) {
3557.         fprintf(stderr, "Could not alloc stream\n");
3558.         ffmpeg_exit(1);
              ^
3559.     }
3560.     ost = new_output_stream(oc, file_idx);

ffmpeg.c:3560:5: Skipping new_output_stream(): empty list of specs
3558.         ffmpeg_exit(1);
3559.     }
3560.     ost = new_output_stream(oc, file_idx);
          ^
3561. 
3562.     if(!audio_stream_copy){

ffmpeg.c:3562:9: Taking true branch
3560.     ost = new_output_stream(oc, file_idx);
3561. 
3562.     if(!audio_stream_copy){
              ^
3563.         if (audio_codec_name) {
3564.             codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1,

ffmpeg.c:3563:13: Taking true branch
3561. 
3562.     if(!audio_stream_copy){
3563.         if (audio_codec_name) {
                  ^
3564.             codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1,
3565.                                          avcodec_opts[AVMEDIA_TYPE_AUDIO]->strict_std_compliance);

ffmpeg.c:3564:13: 
3562.     if(!audio_stream_copy){
3563.         if (audio_codec_name) {
3564.             codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1,
                  ^
3565.                                          avcodec_opts[AVMEDIA_TYPE_AUDIO]->strict_std_compliance);
3566.             codec = avcodec_find_encoder_by_name(audio_codec_name);

ffmpeg.c:3106:1: start of procedure find_codec_or_die()
  3104. }
  3105. 
  3106. static enum CodecID find_codec_or_die(const char *name, int type, int encoder, int strict)
        ^
  3107. {
  3108.     const char *codec_string = encoder ? "encoder" : "decoder";

ffmpeg.c:3108:32: Condition is true
  3106. static enum CodecID find_codec_or_die(const char *name, int type, int encoder, int strict)
  3107. {
  3108.     const char *codec_string = encoder ? "encoder" : "decoder";
                                       ^
  3109.     AVCodec *codec;
  3110. 

ffmpeg.c:3108:5: 
  3106. static enum CodecID find_codec_or_die(const char *name, int type, int encoder, int strict)
  3107. {
  3108.     const char *codec_string = encoder ? "encoder" : "decoder";
            ^
  3109.     AVCodec *codec;
  3110. 

ffmpeg.c:3111:9: Taking false branch
  3109.     AVCodec *codec;
  3110. 
  3111.     if(!name)
                ^
  3112.         return CODEC_ID_NONE;
  3113.     codec = encoder ?

ffmpeg.c:3113:13: Condition is true
  3111.     if(!name)
  3112.         return CODEC_ID_NONE;
  3113.     codec = encoder ?
                    ^
  3114.         avcodec_find_encoder_by_name(name) :
  3115.         avcodec_find_decoder_by_name(name);

ffmpeg.c:3113:5: 
  3111.     if(!name)
  3112.         return CODEC_ID_NONE;
  3113.     codec = encoder ?
            ^
  3114.         avcodec_find_encoder_by_name(name) :
  3115.         avcodec_find_decoder_by_name(name);

ffmpeg.c:3116:9: Taking false branch
  3114.         avcodec_find_encoder_by_name(name) :
  3115.         avcodec_find_decoder_by_name(name);
  3116.     if(!codec) {
                ^
  3117.         fprintf(stderr, "Unknown %s '%s'\n", codec_string, name);
  3118.         ffmpeg_exit(1);

ffmpeg.c:3120:8: Taking false branch
  3118.         ffmpeg_exit(1);
  3119.     }
  3120.     if(codec->type != type) {
               ^
  3121.         fprintf(stderr, "Invalid %s type '%s'\n", codec_string, name);
  3122.         ffmpeg_exit(1);

ffmpeg.c:3124:8: Taking false branch
  3122.         ffmpeg_exit(1);
  3123.     }
  3124.     if(codec->capabilities & CODEC_CAP_EXPERIMENTAL &&
               ^
  3125.        strict > FF_COMPLIANCE_EXPERIMENTAL) {
  3126.         fprintf(stderr, "%s '%s' is experimental and might produce bad "

ffmpeg.c:3137:5: 
  3135.         ffmpeg_exit(1);
  3136.     }
  3137.     return codec->id;
            ^
  3138. }
  3139. 

ffmpeg.c:3138:1: return from a call to find_codec_or_die
  3136.     }
  3137.     return codec->id;
  3138. }
        ^
  3139. 
  3140. static int opt_input_file(const char *opt, const char *filename)

ffmpeg.c:3566:13: Skipping avcodec_find_encoder_by_name(): empty list of specs
3564.             codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1,
3565.                                          avcodec_opts[AVMEDIA_TYPE_AUDIO]->strict_std_compliance);
3566.             codec = avcodec_find_encoder_by_name(audio_codec_name);
                  ^
3567.             ost->enc = codec;
3568.         } else {

ffmpeg.c:3567:13: 
3565.                                          avcodec_opts[AVMEDIA_TYPE_AUDIO]->strict_std_compliance);
3566.             codec = avcodec_find_encoder_by_name(audio_codec_name);
3567.             ost->enc = codec;
                  ^
3568.         } else {
3569.             codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_AUDIO);

ffmpeg.c:3574:5: 
3572.     }
3573. 
3574.     avcodec_get_context_defaults3(st->codec, codec);
          ^
3575. 
3576.     ost->bitstream_filters = audio_bitstream_filters;

static void new_audio_stream(AVFormatContext *oc, int file_idx)
{
    AVStream *st;
    AVOutputStream *ost;
    AVCodec *codec= NULL;
    AVCodecContext *audio_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);
    if(!audio_stream_copy){
        if (audio_codec_name) {
            codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1,
                                         avcodec_opts[AVMEDIA_TYPE_AUDIO]->strict_std_compliance);
            codec = avcodec_find_encoder_by_name(audio_codec_name);
            ost->enc = codec;
        } else {
            codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_AUDIO);
            codec = avcodec_find_encoder(codec_id);
        }
    }
    avcodec_get_context_defaults3(st->codec, codec);
    ost->bitstream_filters = audio_bitstream_filters;
    audio_bitstream_filters= NULL;
    st->codec->thread_count= thread_count;
    audio_enc = st->codec;
    audio_enc->codec_type = AVMEDIA_TYPE_AUDIO;
    if(audio_codec_tag)
        audio_enc->codec_tag= audio_codec_tag;
    if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
        audio_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;
        avcodec_opts[AVMEDIA_TYPE_AUDIO]->flags|= CODEC_FLAG_GLOBAL_HEADER;
    }
    if (audio_stream_copy) {
        st->stream_copy = 1;
    } else {
        audio_enc->codec_id = codec_id;
        set_context_opts(audio_enc, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec);
        if (audio_qscale > QSCALE_NONE) {
            audio_enc->flags |= CODEC_FLAG_QSCALE;
            audio_enc->global_quality = st->quality = FF_QP2LAMBDA * audio_qscale;
        }
        if (audio_channels)
            audio_enc->channels = audio_channels;
        audio_enc->sample_fmt = audio_sample_fmt;
        if (audio_sample_rate)
            audio_enc->sample_rate = audio_sample_rate;
        audio_enc->channel_layout = channel_layout;
        choose_sample_fmt(st, codec);
    }
    if (audio_language) {
        av_dict_set(&st->metadata, "language", audio_language, 0);
        av_freep(&audio_language);
    }
    audio_disable = 0;
    av_freep(&audio_codec_name);
    audio_stream_copy = 0;
}
['static void new_audio_stream(AVFormatContext *oc, int file_idx)\n{\n    AVStream *st;\n    AVOutputStream *ost;\n    AVCodec *codec= NULL;\n    AVCodecContext *audio_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    if(!audio_stream_copy){\n        if (audio_codec_name) {\n            codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1,\n                                         avcodec_opts[AVMEDIA_TYPE_AUDIO]->strict_std_compliance);\n            codec = avcodec_find_encoder_by_name(audio_codec_name);\n            ost->enc = codec;\n        } else {\n            codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_AUDIO);\n            codec = avcodec_find_encoder(codec_id);\n        }\n    }\n    avcodec_get_context_defaults3(st->codec, codec);\n    ost->bitstream_filters = audio_bitstream_filters;\n    audio_bitstream_filters= NULL;\n    st->codec->thread_count= thread_count;\n    audio_enc = st->codec;\n    audio_enc->codec_type = AVMEDIA_TYPE_AUDIO;\n    if(audio_codec_tag)\n        audio_enc->codec_tag= audio_codec_tag;\n    if (oc->oformat->flags & AVFMT_GLOBALHEADER) {\n        audio_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;\n        avcodec_opts[AVMEDIA_TYPE_AUDIO]->flags|= CODEC_FLAG_GLOBAL_HEADER;\n    }\n    if (audio_stream_copy) {\n        st->stream_copy = 1;\n    } else {\n        audio_enc->codec_id = codec_id;\n        set_context_opts(audio_enc, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec);\n        if (audio_qscale > QSCALE_NONE) {\n            audio_enc->flags |= CODEC_FLAG_QSCALE;\n            audio_enc->global_quality = st->quality = FF_QP2LAMBDA * audio_qscale;\n        }\n        if (audio_channels)\n            audio_enc->channels = audio_channels;\n        audio_enc->sample_fmt = audio_sample_fmt;\n        if (audio_sample_rate)\n            audio_enc->sample_rate = audio_sample_rate;\n        audio_enc->channel_layout = channel_layout;\n        choose_sample_fmt(st, codec);\n    }\n    if (audio_language) {\n        av_dict_set(&st->metadata, "language", audio_language, 0);\n        av_freep(&audio_language);\n    }\n    audio_disable = 0;\n    av_freep(&audio_codec_name);\n    audio_stream_copy = 0;\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_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}', 'static enum CodecID find_codec_or_die(const char *name, int type, int encoder, int strict)\n{\n    const char *codec_string = encoder ? "encoder" : "decoder";\n    AVCodec *codec;\n    if(!name)\n        return CODEC_ID_NONE;\n    codec = encoder ?\n        avcodec_find_encoder_by_name(name) :\n        avcodec_find_decoder_by_name(name);\n    if(!codec) {\n        fprintf(stderr, "Unknown %s \'%s\'\\n", codec_string, name);\n        ffmpeg_exit(1);\n    }\n    if(codec->type != type) {\n        fprintf(stderr, "Invalid %s type \'%s\'\\n", codec_string, name);\n        ffmpeg_exit(1);\n    }\n    if(codec->capabilities & CODEC_CAP_EXPERIMENTAL &&\n       strict > FF_COMPLIANCE_EXPERIMENTAL) {\n        fprintf(stderr, "%s \'%s\' is experimental and might produce bad "\n                "results.\\nAdd \'-strict experimental\' if you want to use it.\\n",\n                codec_string, codec->name);\n        codec = encoder ?\n            avcodec_find_encoder(codec->id) :\n            avcodec_find_decoder(codec->id);\n        if (!(codec->capabilities & CODEC_CAP_EXPERIMENTAL))\n            fprintf(stderr, "Or use the non experimental %s \'%s\'.\\n",\n                    codec_string, codec->name);\n        ffmpeg_exit(1);\n    }\n    return codec->id;\n}']