libavformat/yop.c:63: error: Null Dereference
  pointer `video_stream` last assigned on line 60 could be null and is dereferenced at line 63, column 5.

libavformat/yop.c:49:1: start of procedure yop_read_header()
47. }
48. 
49. static int yop_read_header(AVFormatContext *s, AVFormatParameters *ap)
    ^
50. {
51.     YopDecContext *yop = s->priv_data;

libavformat/yop.c:51:5: 
49. static int yop_read_header(AVFormatContext *s, AVFormatParameters *ap)
50. {
51.     YopDecContext *yop = s->priv_data;
        ^
52.     AVIOContext *pb  = s->pb;
53. 

libavformat/yop.c:52:5: 
50. {
51.     YopDecContext *yop = s->priv_data;
52.     AVIOContext *pb  = s->pb;
        ^
53. 
54.     AVCodecContext *audio_dec, *video_dec;

libavformat/yop.c:59:5: 
57.     int frame_rate, ret;
58. 
59.     audio_stream = avformat_new_stream(s, NULL);
        ^
60.     video_stream = avformat_new_stream(s, NULL);
61. 

libavformat/utils.c:2670:1: start of procedure avformat_new_stream()
  2668. #endif
  2669. 
  2670. AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c)
        ^
  2671. {
  2672.     AVStream *st;

libavformat/utils.c:2676:9: Taking true branch
  2674.     AVStream **streams;
  2675. 
  2676.     if (s->nb_streams >= INT_MAX/sizeof(*streams))
                ^
  2677.         return NULL;
  2678.     streams = av_realloc(s->streams, (s->nb_streams + 1) * sizeof(*streams));

libavformat/utils.c:2677:9: 
  2675. 
  2676.     if (s->nb_streams >= INT_MAX/sizeof(*streams))
  2677.         return NULL;
                ^
  2678.     streams = av_realloc(s->streams, (s->nb_streams + 1) * sizeof(*streams));
  2679.     if (!streams)

libavformat/utils.c:2718:1: return from a call to avformat_new_stream
  2716.     s->streams[s->nb_streams++] = st;
  2717.     return st;
  2718. }
        ^
  2719. 
  2720. AVProgram *av_new_program(AVFormatContext *ac, int id)

libavformat/yop.c:60:5: 
58. 
59.     audio_stream = avformat_new_stream(s, NULL);
60.     video_stream = avformat_new_stream(s, NULL);
        ^
61. 
62.     // Extra data that will be passed to the decoder

libavformat/utils.c:2670:1: start of procedure avformat_new_stream()
  2668. #endif
  2669. 
  2670. AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c)
        ^
  2671. {
  2672.     AVStream *st;

libavformat/utils.c:2676:9: Taking true branch
  2674.     AVStream **streams;
  2675. 
  2676.     if (s->nb_streams >= INT_MAX/sizeof(*streams))
                ^
  2677.         return NULL;
  2678.     streams = av_realloc(s->streams, (s->nb_streams + 1) * sizeof(*streams));

libavformat/utils.c:2677:9: 
  2675. 
  2676.     if (s->nb_streams >= INT_MAX/sizeof(*streams))
  2677.         return NULL;
                ^
  2678.     streams = av_realloc(s->streams, (s->nb_streams + 1) * sizeof(*streams));
  2679.     if (!streams)

libavformat/utils.c:2718:1: return from a call to avformat_new_stream
  2716.     s->streams[s->nb_streams++] = st;
  2717.     return st;
  2718. }
        ^
  2719. 
  2720. AVProgram *av_new_program(AVFormatContext *ac, int id)

libavformat/yop.c:63:5: 
61. 
62.     // Extra data that will be passed to the decoder
63.     video_stream->codec->extradata_size = 8;
        ^
64. 
65.     video_stream->codec->extradata = av_mallocz(video_stream->codec->extradata_size +

static int yop_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
    YopDecContext *yop = s->priv_data;
    AVIOContext *pb  = s->pb;
    AVCodecContext *audio_dec, *video_dec;
    AVStream *audio_stream, *video_stream;
    int frame_rate, ret;
    audio_stream = avformat_new_stream(s, NULL);
    video_stream = avformat_new_stream(s, NULL);
    video_stream->codec->extradata_size = 8;
    video_stream->codec->extradata = av_mallocz(video_stream->codec->extradata_size +
                                                FF_INPUT_BUFFER_PADDING_SIZE);
    if (!video_stream->codec->extradata)
        return AVERROR(ENOMEM);
    audio_dec               = audio_stream->codec;
    audio_dec->codec_type   = AVMEDIA_TYPE_AUDIO;
    audio_dec->codec_id     = CODEC_ID_ADPCM_IMA_WS;
    audio_dec->channels     = 1;
    audio_dec->sample_rate  = 22050;
    video_dec               = video_stream->codec;
    video_dec->codec_type   = AVMEDIA_TYPE_VIDEO;
    video_dec->codec_id     = CODEC_ID_YOP;
    avio_skip(pb, 6);
    frame_rate              = avio_r8(pb);
    yop->frame_size         = avio_r8(pb) * 2048;
    video_dec->width        = avio_rl16(pb);
    video_dec->height       = avio_rl16(pb);
    video_stream->sample_aspect_ratio = (AVRational){1, 2};
    ret = avio_read(pb, video_dec->extradata, 8);
    if (ret < 8)
        return ret < 0 ? ret : AVERROR_EOF;
    yop->palette_size       = video_dec->extradata[0] * 3 + 4;
    yop->audio_block_length = AV_RL16(video_dec->extradata + 6);
    if (yop->audio_block_length < 920 ||
        yop->audio_block_length + yop->palette_size >= yop->frame_size) {
        av_log(s, AV_LOG_ERROR, "YOP has invalid header\n");
        return AVERROR_INVALIDDATA;
    }
    avio_seek(pb, 2048, SEEK_SET);
    av_set_pts_info(video_stream, 32, 1, frame_rate);
    return 0;
}
['static int yop_read_header(AVFormatContext *s, AVFormatParameters *ap)\n{\n    YopDecContext *yop = s->priv_data;\n    AVIOContext *pb  = s->pb;\n    AVCodecContext *audio_dec, *video_dec;\n    AVStream *audio_stream, *video_stream;\n    int frame_rate, ret;\n    audio_stream = avformat_new_stream(s, NULL);\n    video_stream = avformat_new_stream(s, NULL);\n    video_stream->codec->extradata_size = 8;\n    video_stream->codec->extradata = av_mallocz(video_stream->codec->extradata_size +\n                                                FF_INPUT_BUFFER_PADDING_SIZE);\n    if (!video_stream->codec->extradata)\n        return AVERROR(ENOMEM);\n    audio_dec               = audio_stream->codec;\n    audio_dec->codec_type   = AVMEDIA_TYPE_AUDIO;\n    audio_dec->codec_id     = CODEC_ID_ADPCM_IMA_WS;\n    audio_dec->channels     = 1;\n    audio_dec->sample_rate  = 22050;\n    video_dec               = video_stream->codec;\n    video_dec->codec_type   = AVMEDIA_TYPE_VIDEO;\n    video_dec->codec_id     = CODEC_ID_YOP;\n    avio_skip(pb, 6);\n    frame_rate              = avio_r8(pb);\n    yop->frame_size         = avio_r8(pb) * 2048;\n    video_dec->width        = avio_rl16(pb);\n    video_dec->height       = avio_rl16(pb);\n    video_stream->sample_aspect_ratio = (AVRational){1, 2};\n    ret = avio_read(pb, video_dec->extradata, 8);\n    if (ret < 8)\n        return ret < 0 ? ret : AVERROR_EOF;\n    yop->palette_size       = video_dec->extradata[0] * 3 + 4;\n    yop->audio_block_length = AV_RL16(video_dec->extradata + 6);\n    if (yop->audio_block_length < 920 ||\n        yop->audio_block_length + yop->palette_size >= yop->frame_size) {\n        av_log(s, AV_LOG_ERROR, "YOP has invalid header\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    avio_seek(pb, 2048, SEEK_SET);\n    av_set_pts_info(video_stream, 32, 1, frame_rate);\n    return 0;\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    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}']