libavformat/oggenc.c:215: error: Null Dereference
  pointer `this_pktl` last assigned on line 214 could be null and is dereferenced at line 215, column 9.

libavformat/oggenc.c:205:1: start of procedure ogg_interleave_per_granule()
203. }
204. 
205. int ogg_interleave_per_granule(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
     ^
206. {
207.     AVPacketList *pktl, **next_point, *this_pktl;

libavformat/oggenc.c:208:5: 
206. {
207.     AVPacketList *pktl, **next_point, *this_pktl;
208.     int stream_count = 0;
         ^
209.     int streams[MAX_STREAMS] = {0};
210.     int interleaved = 0;

libavformat/oggenc.c:209:5: 
207.     AVPacketList *pktl, **next_point, *this_pktl;
208.     int stream_count = 0;
209.     int streams[MAX_STREAMS] = {0};
         ^
210.     int interleaved = 0;
211. 

libavformat/oggenc.c:210:5: 
208.     int stream_count = 0;
209.     int streams[MAX_STREAMS] = {0};
210.     int interleaved = 0;
         ^
211. 
212.     if (pkt) {

libavformat/oggenc.c:212:9: Taking true branch
210.     int interleaved = 0;
211. 
212.     if (pkt) {
             ^
213.         AVStream *st = s->streams[pkt->stream_index];
214.         this_pktl = av_mallocz(sizeof(AVPacketList));

libavformat/oggenc.c:213:9: 
211. 
212.     if (pkt) {
213.         AVStream *st = s->streams[pkt->stream_index];
             ^
214.         this_pktl = av_mallocz(sizeof(AVPacketList));
215.         this_pktl->pkt = *pkt;

libavformat/oggenc.c:214:9: 
212.     if (pkt) {
213.         AVStream *st = s->streams[pkt->stream_index];
214.         this_pktl = av_mallocz(sizeof(AVPacketList));
             ^
215.         this_pktl->pkt = *pkt;
216.         if (pkt->destruct == av_destruct_packet)

libavutil/mem.c:132:1: start of procedure av_mallocz()
  130. }
  131. 
  132. void *av_mallocz(unsigned int size)
       ^
  133. {
  134.     void *ptr = av_malloc(size);

libavutil/mem.c:134:5: 
  132. void *av_mallocz(unsigned int size)
  133. {
  134.     void *ptr = av_malloc(size);
           ^
  135.     if (ptr)
  136.         memset(ptr, 0, size);

libavutil/mem.c:42:1: start of procedure av_malloc()
    40.    linker will do it automatically */
    41. 
    42. void *av_malloc(unsigned int size)
        ^
    43. {
    44.     void *ptr;

libavutil/mem.c:50:8: Taking false branch
    48. 
    49.     /* let's disallow possible ambiguous cases */
    50.     if(size > (INT_MAX-16) )
               ^
    51.         return NULL;
    52. 

libavutil/mem.c:61:5: Skipping memalign(): method has no implementation
    59.     ((char*)ptr)[-1]= diff;
    60. #elif defined (HAVE_MEMALIGN)
    61.     ptr = memalign(16,size);
            ^
    62.     /* Why 64?
    63.        Indeed, we should align it:

libavutil/mem.c:91:5: 
    89.     ptr = malloc(size);
    90. #endif
    91.     return ptr;
            ^
    92. }
    93. 

libavutil/mem.c:92:1: return from a call to av_malloc
    90. #endif
    91.     return ptr;
    92. }
        ^
    93. 
    94. void *av_realloc(void *ptr, unsigned int size)

libavutil/mem.c:135:9: Taking false branch
  133. {
  134.     void *ptr = av_malloc(size);
  135.     if (ptr)
               ^
  136.         memset(ptr, 0, size);
  137.     return ptr;

libavutil/mem.c:137:5: 
  135.     if (ptr)
  136.         memset(ptr, 0, size);
  137.     return ptr;
           ^
  138. }
  139. 

libavutil/mem.c:138:1: return from a call to av_mallocz
  136.         memset(ptr, 0, size);
  137.     return ptr;
  138. }
       ^
  139. 
  140. char *av_strdup(const char *s)

libavformat/oggenc.c:215:9: 
213.         AVStream *st = s->streams[pkt->stream_index];
214.         this_pktl = av_mallocz(sizeof(AVPacketList));
215.         this_pktl->pkt = *pkt;
             ^
216.         if (pkt->destruct == av_destruct_packet)
217.             pkt->destruct = NULL; // not shared -> must keep original from being freed

int ogg_interleave_per_granule(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
{
    AVPacketList *pktl, **next_point, *this_pktl;
    int stream_count = 0;
    int streams[MAX_STREAMS] = {0};
    int interleaved = 0;
    if (pkt) {
        AVStream *st = s->streams[pkt->stream_index];
        this_pktl = av_mallocz(sizeof(AVPacketList));
        this_pktl->pkt = *pkt;
        if (pkt->destruct == av_destruct_packet)
            pkt->destruct = NULL;
        else
            av_dup_packet(&this_pktl->pkt);
        next_point = &s->packet_buffer;
        while (*next_point) {
            AVStream *st2 = s->streams[(*next_point)->pkt.stream_index];
            AVPacket *next_pkt = &(*next_point)->pkt;
            int64_t cur_granule, next_granule;
            next_granule = av_rescale_q(next_pkt->pts + next_pkt->duration,
                                        st2->time_base, AV_TIME_BASE_Q);
            cur_granule = av_rescale_q(pkt->pts + pkt->duration,
                                        st->time_base, AV_TIME_BASE_Q);
            if (next_granule > cur_granule)
                break;
            next_point= &(*next_point)->next;
        }
        this_pktl->next= *next_point;
        *next_point= this_pktl;
    }
    pktl = s->packet_buffer;
    while (pktl) {
        if (streams[pktl->pkt.stream_index] == 0)
            stream_count++;
        streams[pktl->pkt.stream_index]++;
        if (streams[pktl->pkt.stream_index] == 2)
            interleaved++;
        pktl = pktl->next;
    }
    if ((s->nb_streams == stream_count && interleaved == stream_count) ||
        (flush && stream_count)) {
        pktl= s->packet_buffer;
        *out= pktl->pkt;
        s->packet_buffer = pktl->next;
        if (flush && streams[out->stream_index] == 1) {
            OGGStreamContext *ogg = s->streams[out->stream_index]->priv_data;
            ogg->eos = 1;
        }
        av_freep(&pktl);
        return 1;
    } else {
        av_init_packet(out);
        return 0;
    }
}
['int ogg_interleave_per_granule(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)\n{\n    AVPacketList *pktl, **next_point, *this_pktl;\n    int stream_count = 0;\n    int streams[MAX_STREAMS] = {0};\n    int interleaved = 0;\n    if (pkt) {\n        AVStream *st = s->streams[pkt->stream_index];\n        this_pktl = av_mallocz(sizeof(AVPacketList));\n        this_pktl->pkt = *pkt;\n        if (pkt->destruct == av_destruct_packet)\n            pkt->destruct = NULL;\n        else\n            av_dup_packet(&this_pktl->pkt);\n        next_point = &s->packet_buffer;\n        while (*next_point) {\n            AVStream *st2 = s->streams[(*next_point)->pkt.stream_index];\n            AVPacket *next_pkt = &(*next_point)->pkt;\n            int64_t cur_granule, next_granule;\n            next_granule = av_rescale_q(next_pkt->pts + next_pkt->duration,\n                                        st2->time_base, AV_TIME_BASE_Q);\n            cur_granule = av_rescale_q(pkt->pts + pkt->duration,\n                                        st->time_base, AV_TIME_BASE_Q);\n            if (next_granule > cur_granule)\n                break;\n            next_point= &(*next_point)->next;\n        }\n        this_pktl->next= *next_point;\n        *next_point= this_pktl;\n    }\n    pktl = s->packet_buffer;\n    while (pktl) {\n        if (streams[pktl->pkt.stream_index] == 0)\n            stream_count++;\n        streams[pktl->pkt.stream_index]++;\n        if (streams[pktl->pkt.stream_index] == 2)\n            interleaved++;\n        pktl = pktl->next;\n    }\n    if ((s->nb_streams == stream_count && interleaved == stream_count) ||\n        (flush && stream_count)) {\n        pktl= s->packet_buffer;\n        *out= pktl->pkt;\n        s->packet_buffer = pktl->next;\n        if (flush && streams[out->stream_index] == 1) {\n            OGGStreamContext *ogg = s->streams[out->stream_index]->priv_data;\n            ogg->eos = 1;\n        }\n        av_freep(&pktl);\n        return 1;\n    } else {\n        av_init_packet(out);\n        return 0;\n    }\n}', 'void *av_mallocz(unsigned int size)\n{\n    void *ptr = av_malloc(size);\n    if (ptr)\n        memset(ptr, 0, size);\n    return ptr;\n}', 'void *av_malloc(unsigned int size)\n{\n    void *ptr;\n#ifdef CONFIG_MEMALIGN_HACK\n    long diff;\n#endif\n    if(size > (INT_MAX-16) )\n        return NULL;\n#ifdef CONFIG_MEMALIGN_HACK\n    ptr = malloc(size+16);\n    if(!ptr)\n        return ptr;\n    diff= ((-(long)ptr - 1)&15) + 1;\n    ptr = (char*)ptr + diff;\n    ((char*)ptr)[-1]= diff;\n#elif defined (HAVE_MEMALIGN)\n    ptr = memalign(16,size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}']