libavformat/oggparsespeex.c:71: error: Null Dereference
  pointer `st->codec->extradata` last assigned on line 69 could be null and is dereferenced by call to `memcpy()` at line 71, column 9.

libavformat/oggparsespeex.c:40:1: start of procedure speex_header()
38. };
39. 
40. static int speex_header(AVFormatContext *s, int idx) {
    ^
41.     struct ogg *ogg = s->priv_data;
42.     struct ogg_stream *os = ogg->streams + idx;

libavformat/oggparsespeex.c:41:5: 
39. 
40. static int speex_header(AVFormatContext *s, int idx) {
41.     struct ogg *ogg = s->priv_data;
        ^
42.     struct ogg_stream *os = ogg->streams + idx;
43.     struct speex_params *spxp = os->private;

libavformat/oggparsespeex.c:42:5: 
40. static int speex_header(AVFormatContext *s, int idx) {
41.     struct ogg *ogg = s->priv_data;
42.     struct ogg_stream *os = ogg->streams + idx;
        ^
43.     struct speex_params *spxp = os->private;
44.     AVStream *st = s->streams[idx];

libavformat/oggparsespeex.c:43:5: 
41.     struct ogg *ogg = s->priv_data;
42.     struct ogg_stream *os = ogg->streams + idx;
43.     struct speex_params *spxp = os->private;
        ^
44.     AVStream *st = s->streams[idx];
45.     uint8_t *p = os->buf + os->pstart;

libavformat/oggparsespeex.c:44:5: 
42.     struct ogg_stream *os = ogg->streams + idx;
43.     struct speex_params *spxp = os->private;
44.     AVStream *st = s->streams[idx];
        ^
45.     uint8_t *p = os->buf + os->pstart;
46. 

libavformat/oggparsespeex.c:45:5: 
43.     struct speex_params *spxp = os->private;
44.     AVStream *st = s->streams[idx];
45.     uint8_t *p = os->buf + os->pstart;
        ^
46. 
47.     if (!spxp) {

libavformat/oggparsespeex.c:47:10: Taking false branch
45.     uint8_t *p = os->buf + os->pstart;
46. 
47.     if (!spxp) {
             ^
48.         spxp = av_mallocz(sizeof(*spxp));
49.         os->private = spxp;

libavformat/oggparsespeex.c:52:9: Taking false branch
50.     }
51. 
52.     if (spxp->seq > 1)
            ^
53.         return 0;
54. 

libavformat/oggparsespeex.c:55:9: Taking true branch
53.         return 0;
54. 
55.     if (spxp->seq == 0) {
            ^
56.         int frames_per_packet;
57.         st->codec->codec_type = AVMEDIA_TYPE_AUDIO;

libavformat/oggparsespeex.c:57:9: 
55.     if (spxp->seq == 0) {
56.         int frames_per_packet;
57.         st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
            ^
58.         st->codec->codec_id = AV_CODEC_ID_SPEEX;
59. 

libavformat/oggparsespeex.c:58:9: 
56.         int frames_per_packet;
57.         st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
58.         st->codec->codec_id = AV_CODEC_ID_SPEEX;
            ^
59. 
60.         st->codec->sample_rate = AV_RL32(p + 36);

libavformat/oggparsespeex.c:60:9: 
58.         st->codec->codec_id = AV_CODEC_ID_SPEEX;
59. 
60.         st->codec->sample_rate = AV_RL32(p + 36);
            ^
61.         st->codec->channels = AV_RL32(p + 48);
62. 

libavutil/ppc/intreadwrite.h:44:1: start of procedure AV_RL32()
  42. 
  43. #define AV_RL32 AV_RL32
  44. static av_always_inline uint32_t AV_RL32(const void *p)
      ^
  45. {
  46.     uint32_t v;

libavutil/ppc/intreadwrite.h:47:5: Skipping __infer_skip_gcc_asm_stmt(): function or method not found
  45. {
  46.     uint32_t v;
  47.     __asm__ ("lwbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint32_t*)p));
          ^
  48.     return v;
  49. }

libavutil/ppc/intreadwrite.h:48:5: 
  46.     uint32_t v;
  47.     __asm__ ("lwbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint32_t*)p));
  48.     return v;
          ^
  49. }
  50. 

libavutil/ppc/intreadwrite.h:49:1: return from a call to AV_RL32
  47.     __asm__ ("lwbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint32_t*)p));
  48.     return v;
  49. }
      ^
  50. 
  51. #define AV_WL32 AV_WL32

libavformat/oggparsespeex.c:61:9: 
59. 
60.         st->codec->sample_rate = AV_RL32(p + 36);
61.         st->codec->channels = AV_RL32(p + 48);
            ^
62. 
63.         spxp->packet_size  = AV_RL32(p + 56);

libavutil/ppc/intreadwrite.h:44:1: start of procedure AV_RL32()
  42. 
  43. #define AV_RL32 AV_RL32
  44. static av_always_inline uint32_t AV_RL32(const void *p)
      ^
  45. {
  46.     uint32_t v;

libavutil/ppc/intreadwrite.h:47:5: Skipping __infer_skip_gcc_asm_stmt(): function or method not found
  45. {
  46.     uint32_t v;
  47.     __asm__ ("lwbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint32_t*)p));
          ^
  48.     return v;
  49. }

libavutil/ppc/intreadwrite.h:48:5: 
  46.     uint32_t v;
  47.     __asm__ ("lwbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint32_t*)p));
  48.     return v;
          ^
  49. }
  50. 

libavutil/ppc/intreadwrite.h:49:1: return from a call to AV_RL32
  47.     __asm__ ("lwbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint32_t*)p));
  48.     return v;
  49. }
      ^
  50. 
  51. #define AV_WL32 AV_WL32

libavformat/oggparsespeex.c:63:9: 
61.         st->codec->channels = AV_RL32(p + 48);
62. 
63.         spxp->packet_size  = AV_RL32(p + 56);
            ^
64.         frames_per_packet  = AV_RL32(p + 64);
65.         if (frames_per_packet)

libavutil/ppc/intreadwrite.h:44:1: start of procedure AV_RL32()
  42. 
  43. #define AV_RL32 AV_RL32
  44. static av_always_inline uint32_t AV_RL32(const void *p)
      ^
  45. {
  46.     uint32_t v;

libavutil/ppc/intreadwrite.h:47:5: Skipping __infer_skip_gcc_asm_stmt(): function or method not found
  45. {
  46.     uint32_t v;
  47.     __asm__ ("lwbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint32_t*)p));
          ^
  48.     return v;
  49. }

libavutil/ppc/intreadwrite.h:48:5: 
  46.     uint32_t v;
  47.     __asm__ ("lwbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint32_t*)p));
  48.     return v;
          ^
  49. }
  50. 

libavutil/ppc/intreadwrite.h:49:1: return from a call to AV_RL32
  47.     __asm__ ("lwbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint32_t*)p));
  48.     return v;
  49. }
      ^
  50. 
  51. #define AV_WL32 AV_WL32

libavformat/oggparsespeex.c:64:9: 
62. 
63.         spxp->packet_size  = AV_RL32(p + 56);
64.         frames_per_packet  = AV_RL32(p + 64);
            ^
65.         if (frames_per_packet)
66.             spxp->packet_size *= frames_per_packet;

libavutil/ppc/intreadwrite.h:44:1: start of procedure AV_RL32()
  42. 
  43. #define AV_RL32 AV_RL32
  44. static av_always_inline uint32_t AV_RL32(const void *p)
      ^
  45. {
  46.     uint32_t v;

libavutil/ppc/intreadwrite.h:47:5: Skipping __infer_skip_gcc_asm_stmt(): function or method not found
  45. {
  46.     uint32_t v;
  47.     __asm__ ("lwbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint32_t*)p));
          ^
  48.     return v;
  49. }

libavutil/ppc/intreadwrite.h:48:5: 
  46.     uint32_t v;
  47.     __asm__ ("lwbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint32_t*)p));
  48.     return v;
          ^
  49. }
  50. 

libavutil/ppc/intreadwrite.h:49:1: return from a call to AV_RL32
  47.     __asm__ ("lwbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint32_t*)p));
  48.     return v;
  49. }
      ^
  50. 
  51. #define AV_WL32 AV_WL32

libavformat/oggparsespeex.c:65:13: Taking true branch
63.         spxp->packet_size  = AV_RL32(p + 56);
64.         frames_per_packet  = AV_RL32(p + 64);
65.         if (frames_per_packet)
                ^
66.             spxp->packet_size *= frames_per_packet;
67. 

libavformat/oggparsespeex.c:66:13: 
64.         frames_per_packet  = AV_RL32(p + 64);
65.         if (frames_per_packet)
66.             spxp->packet_size *= frames_per_packet;
                ^
67. 
68.         st->codec->extradata_size = os->psize;

libavformat/oggparsespeex.c:68:9: 
66.             spxp->packet_size *= frames_per_packet;
67. 
68.         st->codec->extradata_size = os->psize;
            ^
69.         st->codec->extradata = av_malloc(st->codec->extradata_size
70.                                          + FF_INPUT_BUFFER_PADDING_SIZE);

libavformat/oggparsespeex.c:69:9: 
67. 
68.         st->codec->extradata_size = os->psize;
69.         st->codec->extradata = av_malloc(st->codec->extradata_size
            ^
70.                                          + FF_INPUT_BUFFER_PADDING_SIZE);
71.         memcpy(st->codec->extradata, p, st->codec->extradata_size);

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

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

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

libavutil/mem.c:75:9: 
  73.     /* let's disallow possible ambiguous cases */
  74.     if (size > (INT_MAX - 32) || !size)
  75.         return NULL;
              ^
  76. 
  77. #if CONFIG_MEMALIGN_HACK

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

libavformat/oggparsespeex.c:71:9: 
69.         st->codec->extradata = av_malloc(st->codec->extradata_size
70.                                          + FF_INPUT_BUFFER_PADDING_SIZE);
71.         memcpy(st->codec->extradata, p, st->codec->extradata_size);
            ^
72. 
73.         avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);

static int speex_header(AVFormatContext *s, int idx) {
    struct ogg *ogg = s->priv_data;
    struct ogg_stream *os = ogg->streams + idx;
    struct speex_params *spxp = os->private;
    AVStream *st = s->streams[idx];
    uint8_t *p = os->buf + os->pstart;
    if (!spxp) {
        spxp = av_mallocz(sizeof(*spxp));
        os->private = spxp;
    }
    if (spxp->seq > 1)
        return 0;
    if (spxp->seq == 0) {
        int frames_per_packet;
        st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
        st->codec->codec_id = AV_CODEC_ID_SPEEX;
        st->codec->sample_rate = AV_RL32(p + 36);
        st->codec->channels = AV_RL32(p + 48);
        spxp->packet_size  = AV_RL32(p + 56);
        frames_per_packet  = AV_RL32(p + 64);
        if (frames_per_packet)
            spxp->packet_size *= frames_per_packet;
        st->codec->extradata_size = os->psize;
        st->codec->extradata = av_malloc(st->codec->extradata_size
                                         + FF_INPUT_BUFFER_PADDING_SIZE);
        memcpy(st->codec->extradata, p, st->codec->extradata_size);
        avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
    } else
        ff_vorbis_comment(s, &st->metadata, p, os->psize);
    spxp->seq++;
    return 1;
}
['static int speex_header(AVFormatContext *s, int idx) {\n    struct ogg *ogg = s->priv_data;\n    struct ogg_stream *os = ogg->streams + idx;\n    struct speex_params *spxp = os->private;\n    AVStream *st = s->streams[idx];\n    uint8_t *p = os->buf + os->pstart;\n    if (!spxp) {\n        spxp = av_mallocz(sizeof(*spxp));\n        os->private = spxp;\n    }\n    if (spxp->seq > 1)\n        return 0;\n    if (spxp->seq == 0) {\n        int frames_per_packet;\n        st->codec->codec_type = AVMEDIA_TYPE_AUDIO;\n        st->codec->codec_id = AV_CODEC_ID_SPEEX;\n        st->codec->sample_rate = AV_RL32(p + 36);\n        st->codec->channels = AV_RL32(p + 48);\n        spxp->packet_size  = AV_RL32(p + 56);\n        frames_per_packet  = AV_RL32(p + 64);\n        if (frames_per_packet)\n            spxp->packet_size *= frames_per_packet;\n        st->codec->extradata_size = os->psize;\n        st->codec->extradata = av_malloc(st->codec->extradata_size\n                                         + FF_INPUT_BUFFER_PADDING_SIZE);\n        memcpy(st->codec->extradata, p, st->codec->extradata_size);\n        avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);\n    } else\n        ff_vorbis_comment(s, &st->metadata, p, os->psize);\n    spxp->seq++;\n    return 1;\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}']