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

libavformat/nutdec.c:785:1: start of procedure decode_frame()
783. }
784. 
785. static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code)
     ^
786. {
787.     AVFormatContext *s = nut->avf;

libavformat/nutdec.c:787:5: 
785. static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code)
786. {
787.     AVFormatContext *s = nut->avf;
         ^
788.     AVIOContext *bc    = s->pb;
789.     int size, stream_id, discard;

libavformat/nutdec.c:788:5: 
786. {
787.     AVFormatContext *s = nut->avf;
788.     AVIOContext *bc    = s->pb;
         ^
789.     int size, stream_id, discard;
790.     int64_t pts, last_IP_pts;

libavformat/nutdec.c:794:5: Skipping decode_frame_header(): empty list of specs
792.     uint8_t header_idx;
793. 
794.     size = decode_frame_header(nut, &pts, &stream_id, &header_idx, frame_code);
         ^
795.     if (size < 0)
796.         return size;

libavformat/nutdec.c:795:9: Taking false branch
793. 
794.     size = decode_frame_header(nut, &pts, &stream_id, &header_idx, frame_code);
795.     if (size < 0)
             ^
796.         return size;
797. 

libavformat/nutdec.c:798:5: 
796.         return size;
797. 
798.     stc = &nut->stream[stream_id];
         ^
799. 
800.     if (stc->last_flags & FLAG_KEY)

libavformat/nutdec.c:800:9: Taking true branch
798.     stc = &nut->stream[stream_id];
799. 
800.     if (stc->last_flags & FLAG_KEY)
             ^
801.         stc->skip_until_key_frame = 0;
802. 

libavformat/nutdec.c:801:9: 
799. 
800.     if (stc->last_flags & FLAG_KEY)
801.         stc->skip_until_key_frame = 0;
             ^
802. 
803.     discard     = s->streams[stream_id]->discard;

libavformat/nutdec.c:803:5: 
801.         stc->skip_until_key_frame = 0;
802. 
803.     discard     = s->streams[stream_id]->discard;
         ^
804.     last_IP_pts = s->streams[stream_id]->last_IP_pts;
805.     if ((discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY)) ||

libavformat/nutdec.c:804:5: 
802. 
803.     discard     = s->streams[stream_id]->discard;
804.     last_IP_pts = s->streams[stream_id]->last_IP_pts;
         ^
805.     if ((discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY)) ||
806.         (discard >= AVDISCARD_BIDIR  && last_IP_pts != AV_NOPTS_VALUE &&

libavformat/nutdec.c:805:10: Taking false branch
803.     discard     = s->streams[stream_id]->discard;
804.     last_IP_pts = s->streams[stream_id]->last_IP_pts;
805.     if ((discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY)) ||
              ^
806.         (discard >= AVDISCARD_BIDIR  && last_IP_pts != AV_NOPTS_VALUE &&
807.          last_IP_pts > pts) ||

libavformat/nutdec.c:806:10: Taking true branch
804.     last_IP_pts = s->streams[stream_id]->last_IP_pts;
805.     if ((discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY)) ||
806.         (discard >= AVDISCARD_BIDIR  && last_IP_pts != AV_NOPTS_VALUE &&
              ^
807.          last_IP_pts > pts) ||
808.         discard >= AVDISCARD_ALL ||

libavformat/nutdec.c:806:41: Taking true branch
804.     last_IP_pts = s->streams[stream_id]->last_IP_pts;
805.     if ((discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY)) ||
806.         (discard >= AVDISCARD_BIDIR  && last_IP_pts != AV_NOPTS_VALUE &&
                                             ^
807.          last_IP_pts > pts) ||
808.         discard >= AVDISCARD_ALL ||

libavformat/nutdec.c:807:10: Taking false branch
805.     if ((discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY)) ||
806.         (discard >= AVDISCARD_BIDIR  && last_IP_pts != AV_NOPTS_VALUE &&
807.          last_IP_pts > pts) ||
              ^
808.         discard >= AVDISCARD_ALL ||
809.         stc->skip_until_key_frame) {

libavformat/nutdec.c:808:9: Taking false branch
806.         (discard >= AVDISCARD_BIDIR  && last_IP_pts != AV_NOPTS_VALUE &&
807.          last_IP_pts > pts) ||
808.         discard >= AVDISCARD_ALL ||
             ^
809.         stc->skip_until_key_frame) {
810.         avio_skip(bc, size);

libavformat/nutdec.c:809:9: Taking false branch
807.          last_IP_pts > pts) ||
808.         discard >= AVDISCARD_ALL ||
809.         stc->skip_until_key_frame) {
             ^
810.         avio_skip(bc, size);
811.         return 1;

libavformat/nutdec.c:814:5: 
812.     }
813. 
814.     av_new_packet(pkt, size + nut->header_len[header_idx]);
         ^
815.     memcpy(pkt->data, nut->header[header_idx], nut->header_len[header_idx]);
816.     pkt->pos = avio_tell(bc); // FIXME

libavcodec/avpacket.c:56:1: start of procedure av_new_packet()
  54. }
  55. 
  56. int av_new_packet(AVPacket *pkt, int size)
      ^
  57. {
  58.     uint8_t *data = NULL;

libavcodec/avpacket.c:58:5: 
  56. int av_new_packet(AVPacket *pkt, int size)
  57. {
  58.     uint8_t *data = NULL;
          ^
  59.     if ((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
  60.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);

libavcodec/avpacket.c:59:9: Taking true branch
  57. {
  58.     uint8_t *data = NULL;
  59.     if ((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
              ^
  60.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
  61.     if (data) {

libavcodec/avpacket.c:60:9: 
  58.     uint8_t *data = NULL;
  59.     if ((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
  60.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
              ^
  61.     if (data) {
  62.         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(size_t size)
        ^
    65. {
    66.     void *ptr = NULL;

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

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

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

libavutil/mem.c:73:9: 
    71.     /* let's disallow possible ambiguous cases */
    72.     if (size > (INT_MAX - 32) || !size)
    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, size_t size)

libavcodec/avpacket.c:61:9: Taking false branch
  59.     if ((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
  60.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
  61.     if (data) {
              ^
  62.         memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
  63.     } else

libavcodec/avpacket.c:64:9: 
  62.         memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
  63.     } else
  64.         size = 0;
              ^
  65. 
  66.     av_init_packet(pkt);

libavcodec/avpacket.c:66:5: 
  64.         size = 0;
  65. 
  66.     av_init_packet(pkt);
          ^
  67.     pkt->data     = data;
  68.     pkt->size     = size;

libavcodec/avpacket.c:42:1: start of procedure av_init_packet()
    40. }
    41. 
    42. void av_init_packet(AVPacket *pkt)
        ^
    43. {
    44.     pkt->pts                  = AV_NOPTS_VALUE;

libavcodec/avpacket.c:44:5: 
    42. void av_init_packet(AVPacket *pkt)
    43. {
    44.     pkt->pts                  = AV_NOPTS_VALUE;
            ^
    45.     pkt->dts                  = AV_NOPTS_VALUE;
    46.     pkt->pos                  = -1;

libavcodec/avpacket.c:45:5: 
    43. {
    44.     pkt->pts                  = AV_NOPTS_VALUE;
    45.     pkt->dts                  = AV_NOPTS_VALUE;
            ^
    46.     pkt->pos                  = -1;
    47.     pkt->duration             = 0;

libavcodec/avpacket.c:46:5: 
    44.     pkt->pts                  = AV_NOPTS_VALUE;
    45.     pkt->dts                  = AV_NOPTS_VALUE;
    46.     pkt->pos                  = -1;
            ^
    47.     pkt->duration             = 0;
    48.     pkt->convergence_duration = 0;

libavcodec/avpacket.c:47:5: 
    45.     pkt->dts                  = AV_NOPTS_VALUE;
    46.     pkt->pos                  = -1;
    47.     pkt->duration             = 0;
            ^
    48.     pkt->convergence_duration = 0;
    49.     pkt->flags                = 0;

libavcodec/avpacket.c:48:5: 
    46.     pkt->pos                  = -1;
    47.     pkt->duration             = 0;
    48.     pkt->convergence_duration = 0;
            ^
    49.     pkt->flags                = 0;
    50.     pkt->stream_index         = 0;

libavcodec/avpacket.c:49:5: 
    47.     pkt->duration             = 0;
    48.     pkt->convergence_duration = 0;
    49.     pkt->flags                = 0;
            ^
    50.     pkt->stream_index         = 0;
    51.     pkt->destruct             = NULL;

libavcodec/avpacket.c:50:5: 
    48.     pkt->convergence_duration = 0;
    49.     pkt->flags                = 0;
    50.     pkt->stream_index         = 0;
            ^
    51.     pkt->destruct             = NULL;
    52.     pkt->side_data            = NULL;

libavcodec/avpacket.c:51:5: 
    49.     pkt->flags                = 0;
    50.     pkt->stream_index         = 0;
    51.     pkt->destruct             = NULL;
            ^
    52.     pkt->side_data            = NULL;
    53.     pkt->side_data_elems      = 0;

libavcodec/avpacket.c:52:5: 
    50.     pkt->stream_index         = 0;
    51.     pkt->destruct             = NULL;
    52.     pkt->side_data            = NULL;
            ^
    53.     pkt->side_data_elems      = 0;
    54. }

libavcodec/avpacket.c:53:5: 
    51.     pkt->destruct             = NULL;
    52.     pkt->side_data            = NULL;
    53.     pkt->side_data_elems      = 0;
            ^
    54. }
    55. 

libavcodec/avpacket.c:54:1: return from a call to av_init_packet
    52.     pkt->side_data            = NULL;
    53.     pkt->side_data_elems      = 0;
    54. }
        ^
    55. 
    56. int av_new_packet(AVPacket *pkt, int size)

libavcodec/avpacket.c:67:5: 
  65. 
  66.     av_init_packet(pkt);
  67.     pkt->data     = data;
          ^
  68.     pkt->size     = size;
  69.     pkt->destruct = av_destruct_packet;

libavcodec/avpacket.c:68:5: 
  66.     av_init_packet(pkt);
  67.     pkt->data     = data;
  68.     pkt->size     = size;
          ^
  69.     pkt->destruct = av_destruct_packet;
  70.     if (!data)

libavcodec/avpacket.c:69:5: 
  67.     pkt->data     = data;
  68.     pkt->size     = size;
  69.     pkt->destruct = av_destruct_packet;
          ^
  70.     if (!data)
  71.         return AVERROR(ENOMEM);

libavcodec/avpacket.c:70:10: Taking true branch
  68.     pkt->size     = size;
  69.     pkt->destruct = av_destruct_packet;
  70.     if (!data)
               ^
  71.         return AVERROR(ENOMEM);
  72.     return 0;

libavcodec/avpacket.c:71:9: 
  69.     pkt->destruct = av_destruct_packet;
  70.     if (!data)
  71.         return AVERROR(ENOMEM);
              ^
  72.     return 0;
  73. }

libavcodec/avpacket.c:73:1: return from a call to av_new_packet
  71.         return AVERROR(ENOMEM);
  72.     return 0;
  73. }
      ^
  74. 
  75. void av_shrink_packet(AVPacket *pkt, int size)

libavformat/nutdec.c:815:5: 
813. 
814.     av_new_packet(pkt, size + nut->header_len[header_idx]);
815.     memcpy(pkt->data, nut->header[header_idx], nut->header_len[header_idx]);
         ^
816.     pkt->pos = avio_tell(bc); // FIXME
817.     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_skip(bc, size);
        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{\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 &&\n         last_IP_pts > pts) ||\n        discard >= AVDISCARD_ALL ||\n        stc->skip_until_key_frame) {\n        avio_skip(bc, size);\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(size_t size)\n{\n    void *ptr = NULL;\n#if CONFIG_MEMALIGN_HACK\n    long diff;\n#endif\n    if (size > (INT_MAX - 32) || !size)\n        return NULL;\n#if CONFIG_MEMALIGN_HACK\n    ptr = malloc(size + 32);\n    if (!ptr)\n        return ptr;\n    diff              = ((-(long)ptr - 1) & 31) + 1;\n    ptr               = (char *)ptr + diff;\n    ((char *)ptr)[-1] = diff;\n#elif HAVE_POSIX_MEMALIGN\n    if (posix_memalign(&ptr, 32, size))\n        ptr = NULL;\n#elif HAVE_ALIGNED_MALLOC\n    ptr = _aligned_malloc(size, 32);\n#elif HAVE_MEMALIGN\n    ptr = memalign(32, 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    pkt->side_data            = NULL;\n    pkt->side_data_elems      = 0;\n}']