libavformat/nutdec.c:765: error: Null Dereference
  pointer `pkt->data` last assigned on line 764 could be null and is dereferenced by call to `memcpy()` at line 765, column 5.

libavformat/nutdec.c:737:1: start of procedure decode_frame()
735. }
736. 
737. static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code){
     ^
738.     AVFormatContext *s= nut->avf;
739.     AVIOContext *bc = s->pb;

libavformat/nutdec.c:738:5: 
736. 
737. static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code){
738.     AVFormatContext *s= nut->avf;
         ^
739.     AVIOContext *bc = s->pb;
740.     int size, stream_id, discard;

libavformat/nutdec.c:739:5: 
737. static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code){
738.     AVFormatContext *s= nut->avf;
739.     AVIOContext *bc = s->pb;
         ^
740.     int size, stream_id, discard;
741.     int64_t pts, last_IP_pts;

libavformat/nutdec.c:745:5: Skipping decode_frame_header(): empty list of specs
743.     uint8_t header_idx;
744. 
745.     size= decode_frame_header(nut, &pts, &stream_id, &header_idx, frame_code);
         ^
746.     if(size < 0)
747.         return size;

libavformat/nutdec.c:746:8: Taking false branch
744. 
745.     size= decode_frame_header(nut, &pts, &stream_id, &header_idx, frame_code);
746.     if(size < 0)
            ^
747.         return size;
748. 

libavformat/nutdec.c:749:5: 
747.         return size;
748. 
749.     stc= &nut->stream[stream_id];
         ^
750. 
751.     if (stc->last_flags & FLAG_KEY)

libavformat/nutdec.c:751:9: Taking true branch
749.     stc= &nut->stream[stream_id];
750. 
751.     if (stc->last_flags & FLAG_KEY)
             ^
752.         stc->skip_until_key_frame=0;
753. 

libavformat/nutdec.c:752:9: 
750. 
751.     if (stc->last_flags & FLAG_KEY)
752.         stc->skip_until_key_frame=0;
             ^
753. 
754.     discard= s->streams[ stream_id ]->discard;

libavformat/nutdec.c:754:5: 
752.         stc->skip_until_key_frame=0;
753. 
754.     discard= s->streams[ stream_id ]->discard;
         ^
755.     last_IP_pts= s->streams[ stream_id ]->last_IP_pts;
756.     if(  (discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY))

libavformat/nutdec.c:755:5: 
753. 
754.     discard= s->streams[ stream_id ]->discard;
755.     last_IP_pts= s->streams[ stream_id ]->last_IP_pts;
         ^
756.     if(  (discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY))
757.        ||(discard >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE && last_IP_pts > pts)

libavformat/nutdec.c:756:11: Taking false branch
754.     discard= s->streams[ stream_id ]->discard;
755.     last_IP_pts= s->streams[ stream_id ]->last_IP_pts;
756.     if(  (discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY))
               ^
757.        ||(discard >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE && last_IP_pts > pts)
758.        || discard >= AVDISCARD_ALL

libavformat/nutdec.c:757:11: Taking true branch
755.     last_IP_pts= s->streams[ stream_id ]->last_IP_pts;
756.     if(  (discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY))
757.        ||(discard >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE && last_IP_pts > pts)
               ^
758.        || discard >= AVDISCARD_ALL
759.        || stc->skip_until_key_frame){

libavformat/nutdec.c:757:41: Taking true branch
755.     last_IP_pts= s->streams[ stream_id ]->last_IP_pts;
756.     if(  (discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY))
757.        ||(discard >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE && last_IP_pts > pts)
                                             ^
758.        || discard >= AVDISCARD_ALL
759.        || stc->skip_until_key_frame){

libavformat/nutdec.c:757:74: Taking false branch
755.     last_IP_pts= s->streams[ stream_id ]->last_IP_pts;
756.     if(  (discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY))
757.        ||(discard >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE && last_IP_pts > pts)
                                                                              ^
758.        || discard >= AVDISCARD_ALL
759.        || stc->skip_until_key_frame){

libavformat/nutdec.c:758:11: Taking false branch
756.     if(  (discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY))
757.        ||(discard >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE && last_IP_pts > pts)
758.        || discard >= AVDISCARD_ALL
               ^
759.        || stc->skip_until_key_frame){
760.         avio_seek(bc, size, SEEK_CUR);

libavformat/nutdec.c:759:11: Taking false branch
757.        ||(discard >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE && last_IP_pts > pts)
758.        || discard >= AVDISCARD_ALL
759.        || stc->skip_until_key_frame){
               ^
760.         avio_seek(bc, size, SEEK_CUR);
761.         return 1;

libavformat/nutdec.c:764:5: 
762.     }
763. 
764.     av_new_packet(pkt, size + nut->header_len[header_idx]);
         ^
765.     memcpy(pkt->data, nut->header[header_idx], nut->header_len[header_idx]);
766.     pkt->pos= avio_tell(bc); //FIXME

libavcodec/avpacket.c:49:1: start of procedure av_new_packet()
  47. }
  48. 
  49. int av_new_packet(AVPacket *pkt, int size)
      ^
  50. {
  51.     uint8_t *data= NULL;

libavcodec/avpacket.c:51:5: 
  49. int av_new_packet(AVPacket *pkt, int size)
  50. {
  51.     uint8_t *data= NULL;
          ^
  52.     if((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
  53.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);

libavcodec/avpacket.c:52:8: Taking true branch
  50. {
  51.     uint8_t *data= NULL;
  52.     if((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
             ^
  53.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
  54.     if (data){

libavcodec/avpacket.c:53:9: 
  51.     uint8_t *data= NULL;
  52.     if((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
  53.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
              ^
  54.     if (data){
  55.         memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);

libavutil/mem.c:64:1: start of procedure av_malloc()
    62.    linker will do it automatically. */
    63. 
    64. void *av_malloc(FF_INTERNAL_MEM_TYPE size)
        ^
    65. {
    66.     void *ptr = NULL;

libavutil/mem.c:66:5: 
    64. void *av_malloc(FF_INTERNAL_MEM_TYPE size)
    65. {
    66.     void *ptr = NULL;
            ^
    67. #if CONFIG_MEMALIGN_HACK
    68.     long diff;

libavutil/mem.c:72:8: Taking true branch
    70. 
    71.     /* let's disallow possible ambiguous cases */
    72.     if(size > (INT_MAX-16) )
               ^
    73.         return NULL;
    74. 

libavutil/mem.c:73:9: 
    71.     /* let's disallow possible ambiguous cases */
    72.     if(size > (INT_MAX-16) )
    73.         return NULL;
                ^
    74. 
    75. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:117:1: return from a call to av_malloc
    115. #endif
    116.     return ptr;
    117. }
         ^
    118. 
    119. void *av_realloc(void *ptr, FF_INTERNAL_MEM_TYPE size)

libavcodec/avpacket.c:54:9: Taking false branch
  52.     if((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
  53.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
  54.     if (data){
              ^
  55.         memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
  56.     }else

libavcodec/avpacket.c:57:9: 
  55.         memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
  56.     }else
  57.         size=0;
              ^
  58. 
  59.     av_init_packet(pkt);

libavcodec/avpacket.c:59:5: 
  57.         size=0;
  58. 
  59.     av_init_packet(pkt);
          ^
  60.     pkt->data = data;
  61.     pkt->size = size;

libavcodec/avpacket.c:37:1: start of procedure av_init_packet()
    35. }
    36. 
    37. void av_init_packet(AVPacket *pkt)
        ^
    38. {
    39.     pkt->pts   = AV_NOPTS_VALUE;

libavcodec/avpacket.c:39:5: 
    37. void av_init_packet(AVPacket *pkt)
    38. {
    39.     pkt->pts   = AV_NOPTS_VALUE;
            ^
    40.     pkt->dts   = AV_NOPTS_VALUE;
    41.     pkt->pos   = -1;

libavcodec/avpacket.c:40:5: 
    38. {
    39.     pkt->pts   = AV_NOPTS_VALUE;
    40.     pkt->dts   = AV_NOPTS_VALUE;
            ^
    41.     pkt->pos   = -1;
    42.     pkt->duration = 0;

libavcodec/avpacket.c:41:5: 
    39.     pkt->pts   = AV_NOPTS_VALUE;
    40.     pkt->dts   = AV_NOPTS_VALUE;
    41.     pkt->pos   = -1;
            ^
    42.     pkt->duration = 0;
    43.     pkt->convergence_duration = 0;

libavcodec/avpacket.c:42:5: 
    40.     pkt->dts   = AV_NOPTS_VALUE;
    41.     pkt->pos   = -1;
    42.     pkt->duration = 0;
            ^
    43.     pkt->convergence_duration = 0;
    44.     pkt->flags = 0;

libavcodec/avpacket.c:43:5: 
    41.     pkt->pos   = -1;
    42.     pkt->duration = 0;
    43.     pkt->convergence_duration = 0;
            ^
    44.     pkt->flags = 0;
    45.     pkt->stream_index = 0;

libavcodec/avpacket.c:44:5: 
    42.     pkt->duration = 0;
    43.     pkt->convergence_duration = 0;
    44.     pkt->flags = 0;
            ^
    45.     pkt->stream_index = 0;
    46.     pkt->destruct= NULL;

libavcodec/avpacket.c:45:5: 
    43.     pkt->convergence_duration = 0;
    44.     pkt->flags = 0;
    45.     pkt->stream_index = 0;
            ^
    46.     pkt->destruct= NULL;
    47. }

libavcodec/avpacket.c:46:5: 
    44.     pkt->flags = 0;
    45.     pkt->stream_index = 0;
    46.     pkt->destruct= NULL;
            ^
    47. }
    48. 

libavcodec/avpacket.c:47:1: return from a call to av_init_packet
    45.     pkt->stream_index = 0;
    46.     pkt->destruct= NULL;
    47. }
        ^
    48. 
    49. int av_new_packet(AVPacket *pkt, int size)

libavcodec/avpacket.c:60:5: 
  58. 
  59.     av_init_packet(pkt);
  60.     pkt->data = data;
          ^
  61.     pkt->size = size;
  62.     pkt->destruct = av_destruct_packet;

libavcodec/avpacket.c:61:5: 
  59.     av_init_packet(pkt);
  60.     pkt->data = data;
  61.     pkt->size = size;
          ^
  62.     pkt->destruct = av_destruct_packet;
  63.     if(!data)

libavcodec/avpacket.c:62:5: 
  60.     pkt->data = data;
  61.     pkt->size = size;
  62.     pkt->destruct = av_destruct_packet;
          ^
  63.     if(!data)
  64.         return AVERROR(ENOMEM);

libavcodec/avpacket.c:63:9: Taking true branch
  61.     pkt->size = size;
  62.     pkt->destruct = av_destruct_packet;
  63.     if(!data)
              ^
  64.         return AVERROR(ENOMEM);
  65.     return 0;

libavcodec/avpacket.c:64:9: 
  62.     pkt->destruct = av_destruct_packet;
  63.     if(!data)
  64.         return AVERROR(ENOMEM);
              ^
  65.     return 0;
  66. }

libavcodec/avpacket.c:66:1: return from a call to av_new_packet
  64.         return AVERROR(ENOMEM);
  65.     return 0;
  66. }
      ^
  67. 
  68. void av_shrink_packet(AVPacket *pkt, int size)

libavformat/nutdec.c:765:5: 
763. 
764.     av_new_packet(pkt, size + nut->header_len[header_idx]);
765.     memcpy(pkt->data, nut->header[header_idx], nut->header_len[header_idx]);
         ^
766.     pkt->pos= avio_tell(bc); //FIXME
767.     avio_read(bc, pkt->data + nut->header_len[header_idx], size);

static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code){
    AVFormatContext *s= nut->avf;
    AVIOContext *bc = s->pb;
    int size, stream_id, discard;
    int64_t pts, last_IP_pts;
    StreamContext *stc;
    uint8_t header_idx;
    size= decode_frame_header(nut, &pts, &stream_id, &header_idx, frame_code);
    if(size < 0)
        return size;
    stc= &nut->stream[stream_id];
    if (stc->last_flags & FLAG_KEY)
        stc->skip_until_key_frame=0;
    discard= s->streams[ stream_id ]->discard;
    last_IP_pts= s->streams[ stream_id ]->last_IP_pts;
    if(  (discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY))
       ||(discard >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE && last_IP_pts > pts)
       || discard >= AVDISCARD_ALL
       || stc->skip_until_key_frame){
        avio_seek(bc, size, SEEK_CUR);
        return 1;
    }
    av_new_packet(pkt, size + nut->header_len[header_idx]);
    memcpy(pkt->data, nut->header[header_idx], nut->header_len[header_idx]);
    pkt->pos= avio_tell(bc);
    avio_read(bc, pkt->data + nut->header_len[header_idx], size);
    pkt->stream_index = stream_id;
    if (stc->last_flags & FLAG_KEY)
        pkt->flags |= AV_PKT_FLAG_KEY;
    pkt->pts = pts;
    return 0;
}
['static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code){\n    AVFormatContext *s= nut->avf;\n    AVIOContext *bc = s->pb;\n    int size, stream_id, discard;\n    int64_t pts, last_IP_pts;\n    StreamContext *stc;\n    uint8_t header_idx;\n    size= decode_frame_header(nut, &pts, &stream_id, &header_idx, frame_code);\n    if(size < 0)\n        return size;\n    stc= &nut->stream[stream_id];\n    if (stc->last_flags & FLAG_KEY)\n        stc->skip_until_key_frame=0;\n    discard= s->streams[ stream_id ]->discard;\n    last_IP_pts= s->streams[ stream_id ]->last_IP_pts;\n    if(  (discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY))\n       ||(discard >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE && last_IP_pts > pts)\n       || discard >= AVDISCARD_ALL\n       || stc->skip_until_key_frame){\n        avio_seek(bc, size, SEEK_CUR);\n        return 1;\n    }\n    av_new_packet(pkt, size + nut->header_len[header_idx]);\n    memcpy(pkt->data, nut->header[header_idx], nut->header_len[header_idx]);\n    pkt->pos= avio_tell(bc);\n    avio_read(bc, pkt->data + nut->header_len[header_idx], size);\n    pkt->stream_index = stream_id;\n    if (stc->last_flags & FLAG_KEY)\n        pkt->flags |= AV_PKT_FLAG_KEY;\n    pkt->pts = pts;\n    return 0;\n}', 'int av_new_packet(AVPacket *pkt, int size)\n{\n    uint8_t *data= NULL;\n    if((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)\n        data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);\n    if (data){\n        memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);\n    }else\n        size=0;\n    av_init_packet(pkt);\n    pkt->data = data;\n    pkt->size = size;\n    pkt->destruct = av_destruct_packet;\n    if(!data)\n        return AVERROR(ENOMEM);\n    return 0;\n}', 'void *av_malloc(FF_INTERNAL_MEM_TYPE size)\n{\n    void *ptr = NULL;\n#if CONFIG_MEMALIGN_HACK\n    long diff;\n#endif\n    if(size > (INT_MAX-16) )\n        return NULL;\n#if 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 HAVE_POSIX_MEMALIGN\n    if (posix_memalign(&ptr,16,size))\n        ptr = NULL;\n#elif HAVE_MEMALIGN\n    ptr = memalign(16,size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}', 'void av_init_packet(AVPacket *pkt)\n{\n    pkt->pts   = AV_NOPTS_VALUE;\n    pkt->dts   = AV_NOPTS_VALUE;\n    pkt->pos   = -1;\n    pkt->duration = 0;\n    pkt->convergence_duration = 0;\n    pkt->flags = 0;\n    pkt->stream_index = 0;\n    pkt->destruct= NULL;\n}']