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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

libavformat/gxf.c:102:9: Switch condition is false. Skipping switch case
100.             break;
101.         case 11:
102.         case 12:
             ^
103.         case 20:
104.             st->codec->codec_type = CODEC_TYPE_VIDEO;

libavformat/gxf.c:103:9: Switch condition is false. Skipping switch case
101.         case 11:
102.         case 12:
103.         case 20:
             ^
104.             st->codec->codec_type = CODEC_TYPE_VIDEO;
105.             st->codec->codec_id = CODEC_ID_MPEG2VIDEO;

libavformat/gxf.c:108:9: Switch condition is false. Skipping switch case
106.             st->need_parsing = AVSTREAM_PARSE_HEADERS; //get keyframe flag etc.
107.             break;
108.         case 22:
             ^
109.         case 23:
110.             st->codec->codec_type = CODEC_TYPE_VIDEO;

libavformat/gxf.c:109:9: Switch condition is false. Skipping switch case
107.             break;
108.         case 22:
109.         case 23:
             ^
110.             st->codec->codec_type = CODEC_TYPE_VIDEO;
111.             st->codec->codec_id = CODEC_ID_MPEG1VIDEO;

libavformat/gxf.c:114:9: Switch condition is false. Skipping switch case
112.             st->need_parsing = AVSTREAM_PARSE_HEADERS; //get keyframe flag etc.
113.             break;
114.         case 9:
             ^
115.             st->codec->codec_type = CODEC_TYPE_AUDIO;
116.             st->codec->codec_id = CODEC_ID_PCM_S24LE;

libavformat/gxf.c:123:9: Switch condition is false. Skipping switch case
121.             st->codec->bits_per_sample = 24;
122.             break;
123.         case 10:
             ^
124.             st->codec->codec_type = CODEC_TYPE_AUDIO;
125.             st->codec->codec_id = CODEC_ID_PCM_S16LE;

libavformat/gxf.c:132:9: Switch condition is false. Skipping switch case
130.             st->codec->bits_per_sample = 16;
131.             break;
132.         case 17:
             ^
133.             st->codec->codec_type = CODEC_TYPE_AUDIO;
134.             st->codec->codec_id = CODEC_ID_AC3;

libavformat/gxf.c:139:9: Switch condition is false. Skipping switch case
137.             break;
138.         // timecode tracks:
139.         case 7:
             ^
140.         case 8:
141.         case 24:

libavformat/gxf.c:140:9: Switch condition is false. Skipping switch case
138.         // timecode tracks:
139.         case 7:
140.         case 8:
             ^
141.         case 24:
142.             st->codec->codec_type = CODEC_TYPE_DATA;

libavformat/gxf.c:141:9: Switch condition is false. Skipping switch case
139.         case 7:
140.         case 8:
141.         case 24:
             ^
142.             st->codec->codec_type = CODEC_TYPE_DATA;
143.             st->codec->codec_id = CODEC_ID_NONE;

libavformat/gxf.c:146:13: 
144.             break;
145.         default:
146.             st->codec->codec_type = CODEC_TYPE_UNKNOWN;
                 ^
147.             st->codec->codec_id = CODEC_ID_NONE;
148.             break;

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}']