libavformat/gxf.c:103: error: Null Dereference
  pointer `st` last assigned on line 83 could be null and is dereferenced at line 103, column 13.

libavformat/gxf.c:76:1: start of procedure get_sindex()
74.  * \param format stream format identifier
75.  */
76. static int get_sindex(AVFormatContext *s, int id, int format) {
    ^
77.     int i;
78.     AVStream *st = NULL;

libavformat/gxf.c:78:5: 
76. static int get_sindex(AVFormatContext *s, int id, int format) {
77.     int i;
78.     AVStream *st = NULL;
        ^
79.     for (i = 0; i < s->nb_streams; i++) {
80.         if (s->streams[i]->id == id)

libavformat/gxf.c:79:10: 
77.     int i;
78.     AVStream *st = NULL;
79.     for (i = 0; i < s->nb_streams; i++) {
             ^
80.         if (s->streams[i]->id == id)
81.             return i;

libavformat/gxf.c:79:17: Loop condition is true. Entering loop body
77.     int i;
78.     AVStream *st = NULL;
79.     for (i = 0; i < s->nb_streams; i++) {
                    ^
80.         if (s->streams[i]->id == id)
81.             return i;

libavformat/gxf.c:80:13: Taking false branch
78.     AVStream *st = NULL;
79.     for (i = 0; i < s->nb_streams; i++) {
80.         if (s->streams[i]->id == id)
                ^
81.             return i;
82.     }

libavformat/gxf.c:79:36: 
77.     int i;
78.     AVStream *st = NULL;
79.     for (i = 0; i < s->nb_streams; i++) {
                                       ^
80.         if (s->streams[i]->id == id)
81.             return i;

libavformat/gxf.c:79:17: Loop condition is false. Leaving loop
77.     int i;
78.     AVStream *st = NULL;
79.     for (i = 0; i < s->nb_streams; i++) {
                    ^
80.         if (s->streams[i]->id == id)
81.             return i;

libavformat/gxf.c:83:5: 
81.             return i;
82.     }
83.     st = av_new_stream(s, id);
        ^
84.     switch (format) {
85.         case 3:

libavformat/utils.c:2160:1: start of procedure av_new_stream()
  2158. }
  2159. 
  2160. AVStream *av_new_stream(AVFormatContext *s, int id)
        ^
  2161. {
  2162.     AVStream *st;

libavformat/utils.c:2165:9: Taking true branch
  2163.     int i;
  2164. 
  2165.     if (s->nb_streams >= MAX_STREAMS)
                ^
  2166.         return NULL;
  2167. 

libavformat/utils.c:2166:9: 
  2164. 
  2165.     if (s->nb_streams >= MAX_STREAMS)
  2166.         return NULL;
                ^
  2167. 
  2168.     st = av_mallocz(sizeof(AVStream));

libavformat/utils.c:2192:1: return from a call to av_new_stream
  2190.     s->streams[s->nb_streams++] = st;
  2191.     return st;
  2192. }
        ^
  2193. 
  2194. AVProgram *av_new_program(AVFormatContext *ac, int id)

libavformat/gxf.c:84:5: 
82.     }
83.     st = av_new_stream(s, id);
84.     switch (format) {
        ^
85.         case 3:
86.         case 4:

libavformat/gxf.c:85:9: Switch condition is false. Skipping switch case
83.     st = av_new_stream(s, id);
84.     switch (format) {
85.         case 3:
            ^
86.         case 4:
87.             st->codec->codec_type = CODEC_TYPE_VIDEO;

libavformat/gxf.c:86:9: Switch condition is false. Skipping switch case
84.     switch (format) {
85.         case 3:
86.         case 4:
            ^
87.             st->codec->codec_type = CODEC_TYPE_VIDEO;
88.             st->codec->codec_id = CODEC_ID_MJPEG;

libavformat/gxf.c:90:9: Switch condition is false. Skipping switch case
88.             st->codec->codec_id = CODEC_ID_MJPEG;
89.             break;
90.         case 13:
            ^
91.         case 15:
92.             st->codec->codec_type = CODEC_TYPE_VIDEO;

libavformat/gxf.c:91:9: Switch condition is false. Skipping switch case
89.             break;
90.         case 13:
91.         case 15:
            ^
92.             st->codec->codec_type = CODEC_TYPE_VIDEO;
93.             st->codec->codec_id = CODEC_ID_DVVIDEO;

libavformat/gxf.c:95:9: Switch condition is false. Skipping switch case
93.             st->codec->codec_id = CODEC_ID_DVVIDEO;
94.             break;
95.         case 14:
            ^
96.         case 16:
97.             st->codec->codec_type = CODEC_TYPE_VIDEO;

libavformat/gxf.c:96:9: Switch condition is false. Skipping switch case
94.             break;
95.         case 14:
96.         case 16:
            ^
97.             st->codec->codec_type = CODEC_TYPE_VIDEO;
98.             st->codec->codec_id = CODEC_ID_DVVIDEO;

libavformat/gxf.c:100:9: Switch condition is true. Entering switch case
 98.             st->codec->codec_id = CODEC_ID_DVVIDEO;
 99.             break;
100.         case 11:
             ^
101.         case 12:
102.         case 20:

libavformat/gxf.c:103:13: 
101.         case 12:
102.         case 20:
103.             st->codec->codec_type = CODEC_TYPE_VIDEO;
                 ^
104.             st->codec->codec_id = CODEC_ID_MPEG2VIDEO;
105.             st->need_parsing = AVSTREAM_PARSE_HEADERS; //get keyframe flag etc.

static int get_sindex(AVFormatContext *s, int id, int format) {
    int i;
    AVStream *st = NULL;
    for (i = 0; i < s->nb_streams; i++) {
        if (s->streams[i]->id == id)
            return i;
    }
    st = av_new_stream(s, id);
    switch (format) {
        case 3:
        case 4:
            st->codec->codec_type = CODEC_TYPE_VIDEO;
            st->codec->codec_id = CODEC_ID_MJPEG;
            break;
        case 13:
        case 15:
            st->codec->codec_type = CODEC_TYPE_VIDEO;
            st->codec->codec_id = CODEC_ID_DVVIDEO;
            break;
        case 14:
        case 16:
            st->codec->codec_type = CODEC_TYPE_VIDEO;
            st->codec->codec_id = CODEC_ID_DVVIDEO;
            break;
        case 11:
        case 12:
        case 20:
            st->codec->codec_type = CODEC_TYPE_VIDEO;
            st->codec->codec_id = CODEC_ID_MPEG2VIDEO;
            st->need_parsing = AVSTREAM_PARSE_HEADERS;
            break;
        case 22:
        case 23:
            st->codec->codec_type = CODEC_TYPE_VIDEO;
            st->codec->codec_id = CODEC_ID_MPEG1VIDEO;
            st->need_parsing = AVSTREAM_PARSE_HEADERS;
            break;
        case 9:
            st->codec->codec_type = CODEC_TYPE_AUDIO;
            st->codec->codec_id = CODEC_ID_PCM_S24LE;
            st->codec->channels = 1;
            st->codec->sample_rate = 48000;
            st->codec->bit_rate = 3 * 1 * 48000 * 8;
            st->codec->block_align = 3 * 1;
            st->codec->bits_per_sample = 24;
            break;
        case 10:
            st->codec->codec_type = CODEC_TYPE_AUDIO;
            st->codec->codec_id = CODEC_ID_PCM_S16LE;
            st->codec->channels = 1;
            st->codec->sample_rate = 48000;
            st->codec->bit_rate = 2 * 1 * 48000 * 8;
            st->codec->block_align = 2 * 1;
            st->codec->bits_per_sample = 16;
            break;
        case 17:
            st->codec->codec_type = CODEC_TYPE_AUDIO;
            st->codec->codec_id = CODEC_ID_AC3;
            st->codec->channels = 2;
            st->codec->sample_rate = 48000;
            break;
        case 7:
        case 8:
        case 24:
            st->codec->codec_type = CODEC_TYPE_DATA;
            st->codec->codec_id = CODEC_ID_NONE;
            break;
        default:
            st->codec->codec_type = CODEC_TYPE_UNKNOWN;
            st->codec->codec_id = CODEC_ID_NONE;
            break;
    }
    return s->nb_streams - 1;
}
['static int get_sindex(AVFormatContext *s, int id, int format) {\n    int i;\n    AVStream *st = NULL;\n    for (i = 0; i < s->nb_streams; i++) {\n        if (s->streams[i]->id == id)\n            return i;\n    }\n    st = av_new_stream(s, id);\n    switch (format) {\n        case 3:\n        case 4:\n            st->codec->codec_type = CODEC_TYPE_VIDEO;\n            st->codec->codec_id = CODEC_ID_MJPEG;\n            break;\n        case 13:\n        case 15:\n            st->codec->codec_type = CODEC_TYPE_VIDEO;\n            st->codec->codec_id = CODEC_ID_DVVIDEO;\n            break;\n        case 14:\n        case 16:\n            st->codec->codec_type = CODEC_TYPE_VIDEO;\n            st->codec->codec_id = CODEC_ID_DVVIDEO;\n            break;\n        case 11:\n        case 12:\n        case 20:\n            st->codec->codec_type = CODEC_TYPE_VIDEO;\n            st->codec->codec_id = CODEC_ID_MPEG2VIDEO;\n            st->need_parsing = AVSTREAM_PARSE_HEADERS;\n            break;\n        case 22:\n        case 23:\n            st->codec->codec_type = CODEC_TYPE_VIDEO;\n            st->codec->codec_id = CODEC_ID_MPEG1VIDEO;\n            st->need_parsing = AVSTREAM_PARSE_HEADERS;\n            break;\n        case 9:\n            st->codec->codec_type = CODEC_TYPE_AUDIO;\n            st->codec->codec_id = CODEC_ID_PCM_S24LE;\n            st->codec->channels = 1;\n            st->codec->sample_rate = 48000;\n            st->codec->bit_rate = 3 * 1 * 48000 * 8;\n            st->codec->block_align = 3 * 1;\n            st->codec->bits_per_sample = 24;\n            break;\n        case 10:\n            st->codec->codec_type = CODEC_TYPE_AUDIO;\n            st->codec->codec_id = CODEC_ID_PCM_S16LE;\n            st->codec->channels = 1;\n            st->codec->sample_rate = 48000;\n            st->codec->bit_rate = 2 * 1 * 48000 * 8;\n            st->codec->block_align = 2 * 1;\n            st->codec->bits_per_sample = 16;\n            break;\n        case 17:\n            st->codec->codec_type = CODEC_TYPE_AUDIO;\n            st->codec->codec_id = CODEC_ID_AC3;\n            st->codec->channels = 2;\n            st->codec->sample_rate = 48000;\n            break;\n        case 7:\n        case 8:\n        case 24:\n            st->codec->codec_type = CODEC_TYPE_DATA;\n            st->codec->codec_id = CODEC_ID_NONE;\n            break;\n        default:\n            st->codec->codec_type = CODEC_TYPE_UNKNOWN;\n            st->codec->codec_id = CODEC_ID_NONE;\n            break;\n    }\n    return s->nb_streams - 1;\n}', 'AVStream *av_new_stream(AVFormatContext *s, int id)\n{\n    AVStream *st;\n    int i;\n    if (s->nb_streams >= MAX_STREAMS)\n        return NULL;\n    st = av_mallocz(sizeof(AVStream));\n    if (!st)\n        return NULL;\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 = AV_NOPTS_VALUE;\n    st->first_dts = AV_NOPTS_VALUE;\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    s->streams[s->nb_streams++] = st;\n    return st;\n}']