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

libavformat/rmdec.c:838:1: start of procedure ff_rm_retrieve_cache()
836. }
837. 
838. int
     ^
839. ff_rm_retrieve_cache (AVFormatContext *s, AVIOContext *pb,
840.                       AVStream *st, RMStream *ast, AVPacket *pkt)

libavformat/rmdec.c:842:5: 
840.                       AVStream *st, RMStream *ast, AVPacket *pkt)
841. {
842.     RMDemuxContext *rm = s->priv_data;
         ^
843. 
844.     assert (rm->audio_pkt_cnt > 0);

libavformat/rmdec.c:844:5: 
842.     RMDemuxContext *rm = s->priv_data;
843. 
844.     assert (rm->audio_pkt_cnt > 0);
         ^
845. 
846.     if (ast->deint_id == DEINT_ID_VBRF ||

libavformat/rmdec.c:846:9: Taking false branch
844.     assert (rm->audio_pkt_cnt > 0);
845. 
846.     if (ast->deint_id == DEINT_ID_VBRF ||
             ^
847.         ast->deint_id == DEINT_ID_VBRS)
848.         av_get_packet(pb, pkt, ast->sub_packet_lengths[ast->sub_packet_cnt - rm->audio_pkt_cnt]);

libavformat/rmdec.c:847:9: Taking false branch
845. 
846.     if (ast->deint_id == DEINT_ID_VBRF ||
847.         ast->deint_id == DEINT_ID_VBRS)
             ^
848.         av_get_packet(pb, pkt, ast->sub_packet_lengths[ast->sub_packet_cnt - rm->audio_pkt_cnt]);
849.     else {

libavformat/rmdec.c:850:9: 
848.         av_get_packet(pb, pkt, ast->sub_packet_lengths[ast->sub_packet_cnt - rm->audio_pkt_cnt]);
849.     else {
850.         av_new_packet(pkt, st->codec->block_align);
             ^
851.         memcpy(pkt->data, ast->pkt.data + st->codec->block_align * //FIXME avoid this
852.                (ast->sub_packet_h * ast->audio_framesize / st->codec->block_align - rm->audio_pkt_cnt),

libavcodec/avpacket.c:61:1: start of procedure av_new_packet()
  59. }
  60. 
  61. int av_new_packet(AVPacket *pkt, int size)
      ^
  62. {
  63.     uint8_t *data = NULL;

libavcodec/avpacket.c:63:5: 
  61. int av_new_packet(AVPacket *pkt, int size)
  62. {
  63.     uint8_t *data = NULL;
          ^
  64.     if ((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
  65.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);

libavcodec/avpacket.c:64:9: Taking true branch
  62. {
  63.     uint8_t *data = NULL;
  64.     if ((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
              ^
  65.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
  66.     if (data) {

libavcodec/avpacket.c:65:9: 
  63.     uint8_t *data = NULL;
  64.     if ((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
  65.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
              ^
  66.     if (data) {
  67.         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 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:66:9: Taking false branch
  64.     if ((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
  65.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
  66.     if (data) {
              ^
  67.         memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
  68.     } else

libavcodec/avpacket.c:69:9: 
  67.         memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
  68.     } else
  69.         size = 0;
              ^
  70. 
  71.     av_init_packet(pkt);

libavcodec/avpacket.c:71:5: 
  69.         size = 0;
  70. 
  71.     av_init_packet(pkt);
          ^
  72.     pkt->data     = data;
  73.     pkt->size     = size;

libavcodec/avpacket.c:47:1: start of procedure av_init_packet()
    45. }
    46. 
    47. void av_init_packet(AVPacket *pkt)
        ^
    48. {
    49.     pkt->pts                  = AV_NOPTS_VALUE;

libavcodec/avpacket.c:49:5: 
    47. void av_init_packet(AVPacket *pkt)
    48. {
    49.     pkt->pts                  = AV_NOPTS_VALUE;
            ^
    50.     pkt->dts                  = AV_NOPTS_VALUE;
    51.     pkt->pos                  = -1;

libavcodec/avpacket.c:50:5: 
    48. {
    49.     pkt->pts                  = AV_NOPTS_VALUE;
    50.     pkt->dts                  = AV_NOPTS_VALUE;
            ^
    51.     pkt->pos                  = -1;
    52.     pkt->duration             = 0;

libavcodec/avpacket.c:51:5: 
    49.     pkt->pts                  = AV_NOPTS_VALUE;
    50.     pkt->dts                  = AV_NOPTS_VALUE;
    51.     pkt->pos                  = -1;
            ^
    52.     pkt->duration             = 0;
    53.     pkt->convergence_duration = 0;

libavcodec/avpacket.c:52:5: 
    50.     pkt->dts                  = AV_NOPTS_VALUE;
    51.     pkt->pos                  = -1;
    52.     pkt->duration             = 0;
            ^
    53.     pkt->convergence_duration = 0;
    54.     pkt->flags                = 0;

libavcodec/avpacket.c:53:5: 
    51.     pkt->pos                  = -1;
    52.     pkt->duration             = 0;
    53.     pkt->convergence_duration = 0;
            ^
    54.     pkt->flags                = 0;
    55.     pkt->stream_index         = 0;

libavcodec/avpacket.c:54:5: 
    52.     pkt->duration             = 0;
    53.     pkt->convergence_duration = 0;
    54.     pkt->flags                = 0;
            ^
    55.     pkt->stream_index         = 0;
    56.     pkt->destruct             = NULL;

libavcodec/avpacket.c:55:5: 
    53.     pkt->convergence_duration = 0;
    54.     pkt->flags                = 0;
    55.     pkt->stream_index         = 0;
            ^
    56.     pkt->destruct             = NULL;
    57.     pkt->side_data            = NULL;

libavcodec/avpacket.c:56:5: 
    54.     pkt->flags                = 0;
    55.     pkt->stream_index         = 0;
    56.     pkt->destruct             = NULL;
            ^
    57.     pkt->side_data            = NULL;
    58.     pkt->side_data_elems      = 0;

libavcodec/avpacket.c:57:5: 
    55.     pkt->stream_index         = 0;
    56.     pkt->destruct             = NULL;
    57.     pkt->side_data            = NULL;
            ^
    58.     pkt->side_data_elems      = 0;
    59. }

libavcodec/avpacket.c:58:5: 
    56.     pkt->destruct             = NULL;
    57.     pkt->side_data            = NULL;
    58.     pkt->side_data_elems      = 0;
            ^
    59. }
    60. 

libavcodec/avpacket.c:59:1: return from a call to av_init_packet
    57.     pkt->side_data            = NULL;
    58.     pkt->side_data_elems      = 0;
    59. }
        ^
    60. 
    61. int av_new_packet(AVPacket *pkt, int size)

libavcodec/avpacket.c:72:5: 
  70. 
  71.     av_init_packet(pkt);
  72.     pkt->data     = data;
          ^
  73.     pkt->size     = size;
  74.     pkt->destruct = av_destruct_packet;

libavcodec/avpacket.c:73:5: 
  71.     av_init_packet(pkt);
  72.     pkt->data     = data;
  73.     pkt->size     = size;
          ^
  74.     pkt->destruct = av_destruct_packet;
  75.     if (!data)

libavcodec/avpacket.c:74:5: 
  72.     pkt->data     = data;
  73.     pkt->size     = size;
  74.     pkt->destruct = av_destruct_packet;
          ^
  75.     if (!data)
  76.         return AVERROR(ENOMEM);

libavcodec/avpacket.c:75:10: Taking true branch
  73.     pkt->size     = size;
  74.     pkt->destruct = av_destruct_packet;
  75.     if (!data)
               ^
  76.         return AVERROR(ENOMEM);
  77.     return 0;

libavcodec/avpacket.c:76:9: 
  74.     pkt->destruct = av_destruct_packet;
  75.     if (!data)
  76.         return AVERROR(ENOMEM);
              ^
  77.     return 0;
  78. }

libavcodec/avpacket.c:78:1: return from a call to av_new_packet
  76.         return AVERROR(ENOMEM);
  77.     return 0;
  78. }
      ^
  79. 
  80. void av_shrink_packet(AVPacket *pkt, int size)

libavformat/rmdec.c:851:9: 
849.     else {
850.         av_new_packet(pkt, st->codec->block_align);
851.         memcpy(pkt->data, ast->pkt.data + st->codec->block_align * //FIXME avoid this
             ^
852.                (ast->sub_packet_h * ast->audio_framesize / st->codec->block_align - rm->audio_pkt_cnt),
853.                st->codec->block_align);

int
ff_rm_retrieve_cache (AVFormatContext *s, AVIOContext *pb,
                      AVStream *st, RMStream *ast, AVPacket *pkt)
{
    RMDemuxContext *rm = s->priv_data;
    assert (rm->audio_pkt_cnt > 0);
    if (ast->deint_id == DEINT_ID_VBRF ||
        ast->deint_id == DEINT_ID_VBRS)
        av_get_packet(pb, pkt, ast->sub_packet_lengths[ast->sub_packet_cnt - rm->audio_pkt_cnt]);
    else {
        av_new_packet(pkt, st->codec->block_align);
        memcpy(pkt->data, ast->pkt.data + st->codec->block_align *
               (ast->sub_packet_h * ast->audio_framesize / st->codec->block_align - rm->audio_pkt_cnt),
               st->codec->block_align);
    }
    rm->audio_pkt_cnt--;
    if ((pkt->pts = ast->audiotimestamp) != AV_NOPTS_VALUE) {
        ast->audiotimestamp = AV_NOPTS_VALUE;
        pkt->flags = AV_PKT_FLAG_KEY;
    } else
        pkt->flags = 0;
    pkt->stream_index = st->index;
    return rm->audio_pkt_cnt;
}
['int\nff_rm_retrieve_cache (AVFormatContext *s, AVIOContext *pb,\n                      AVStream *st, RMStream *ast, AVPacket *pkt)\n{\n    RMDemuxContext *rm = s->priv_data;\n    assert (rm->audio_pkt_cnt > 0);\n    if (ast->deint_id == DEINT_ID_VBRF ||\n        ast->deint_id == DEINT_ID_VBRS)\n        av_get_packet(pb, pkt, ast->sub_packet_lengths[ast->sub_packet_cnt - rm->audio_pkt_cnt]);\n    else {\n        av_new_packet(pkt, st->codec->block_align);\n        memcpy(pkt->data, ast->pkt.data + st->codec->block_align *\n               (ast->sub_packet_h * ast->audio_framesize / st->codec->block_align - rm->audio_pkt_cnt),\n               st->codec->block_align);\n    }\n    rm->audio_pkt_cnt--;\n    if ((pkt->pts = ast->audiotimestamp) != AV_NOPTS_VALUE) {\n        ast->audiotimestamp = AV_NOPTS_VALUE;\n        pkt->flags = AV_PKT_FLAG_KEY;\n    } else\n        pkt->flags = 0;\n    pkt->stream_index = st->index;\n    return rm->audio_pkt_cnt;\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}']