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

libavformat/oggparsespeex.c:33:1: start of procedure speex_header()
31. #include "oggdec.h"
32. 
33. static int speex_header(AVFormatContext *s, int idx) {
    ^
34.     struct ogg *ogg = s->priv_data;
35.     struct ogg_stream *os = ogg->streams + idx;

libavformat/oggparsespeex.c:34:5: 
32. 
33. static int speex_header(AVFormatContext *s, int idx) {
34.     struct ogg *ogg = s->priv_data;
        ^
35.     struct ogg_stream *os = ogg->streams + idx;
36.     AVStream *st = s->streams[idx];

libavformat/oggparsespeex.c:35:5: 
33. static int speex_header(AVFormatContext *s, int idx) {
34.     struct ogg *ogg = s->priv_data;
35.     struct ogg_stream *os = ogg->streams + idx;
        ^
36.     AVStream *st = s->streams[idx];
37.     uint8_t *p = os->buf + os->pstart;

libavformat/oggparsespeex.c:36:5: 
34.     struct ogg *ogg = s->priv_data;
35.     struct ogg_stream *os = ogg->streams + idx;
36.     AVStream *st = s->streams[idx];
        ^
37.     uint8_t *p = os->buf + os->pstart;
38. 

libavformat/oggparsespeex.c:37:5: 
35.     struct ogg_stream *os = ogg->streams + idx;
36.     AVStream *st = s->streams[idx];
37.     uint8_t *p = os->buf + os->pstart;
        ^
38. 
39.     if (os->seq > 1)

libavformat/oggparsespeex.c:39:9: Taking false branch
37.     uint8_t *p = os->buf + os->pstart;
38. 
39.     if (os->seq > 1)
            ^
40.         return 0;
41. 

libavformat/oggparsespeex.c:42:9: Taking true branch
40.         return 0;
41. 
42.     if (os->seq == 0) {
            ^
43.         st->codec->codec_type = CODEC_TYPE_AUDIO;
44.         st->codec->codec_id = CODEC_ID_SPEEX;

libavformat/oggparsespeex.c:43:9: 
41. 
42.     if (os->seq == 0) {
43.         st->codec->codec_type = CODEC_TYPE_AUDIO;
            ^
44.         st->codec->codec_id = CODEC_ID_SPEEX;
45. 

libavformat/oggparsespeex.c:44:9: 
42.     if (os->seq == 0) {
43.         st->codec->codec_type = CODEC_TYPE_AUDIO;
44.         st->codec->codec_id = CODEC_ID_SPEEX;
            ^
45. 
46.         st->codec->sample_rate = AV_RL32(p + 36);

libavformat/oggparsespeex.c:46:9: 
44.         st->codec->codec_id = CODEC_ID_SPEEX;
45. 
46.         st->codec->sample_rate = AV_RL32(p + 36);
            ^
47.         st->codec->channels = AV_RL32(p + 48);
48.         st->codec->frame_size = AV_RL32(p + 56);

libavformat/oggparsespeex.c:47:9: 
45. 
46.         st->codec->sample_rate = AV_RL32(p + 36);
47.         st->codec->channels = AV_RL32(p + 48);
            ^
48.         st->codec->frame_size = AV_RL32(p + 56);
49.         st->codec->extradata_size = os->psize;

libavformat/oggparsespeex.c:48:9: 
46.         st->codec->sample_rate = AV_RL32(p + 36);
47.         st->codec->channels = AV_RL32(p + 48);
48.         st->codec->frame_size = AV_RL32(p + 56);
            ^
49.         st->codec->extradata_size = os->psize;
50.         st->codec->extradata = av_malloc(st->codec->extradata_size);

libavformat/oggparsespeex.c:49:9: 
47.         st->codec->channels = AV_RL32(p + 48);
48.         st->codec->frame_size = AV_RL32(p + 56);
49.         st->codec->extradata_size = os->psize;
            ^
50.         st->codec->extradata = av_malloc(st->codec->extradata_size);
51.         memcpy(st->codec->extradata, p, st->codec->extradata_size);

libavformat/oggparsespeex.c:50:9: 
48.         st->codec->frame_size = AV_RL32(p + 56);
49.         st->codec->extradata_size = os->psize;
50.         st->codec->extradata = av_malloc(st->codec->extradata_size);
            ^
51.         memcpy(st->codec->extradata, p, st->codec->extradata_size);
52. 

libavutil/mem.c:47:1: start of procedure av_malloc()
  45.    linker will do it automatically. */
  46. 
  47. void *av_malloc(unsigned int size)
      ^
  48. {
  49.     void *ptr = NULL;

libavutil/mem.c:49:5: 
  47. void *av_malloc(unsigned int size)
  48. {
  49.     void *ptr = NULL;
          ^
  50. #if CONFIG_MEMALIGN_HACK
  51.     long diff;

libavutil/mem.c:55:8: Taking true branch
  53. 
  54.     /* let's disallow possible ambiguous cases */
  55.     if(size > (INT_MAX-16) )
             ^
  56.         return NULL;
  57. 

libavutil/mem.c:56:9: 
  54.     /* let's disallow possible ambiguous cases */
  55.     if(size > (INT_MAX-16) )
  56.         return NULL;
              ^
  57. 
  58. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:100:1: return from a call to av_malloc
   98. #endif
   99.     return ptr;
  100. }
       ^
  101. 
  102. void *av_realloc(void *ptr, unsigned int size)

libavformat/oggparsespeex.c:51:9: 
49.         st->codec->extradata_size = os->psize;
50.         st->codec->extradata = av_malloc(st->codec->extradata_size);
51.         memcpy(st->codec->extradata, p, st->codec->extradata_size);
            ^
52. 
53.         st->time_base.num = 1;

static int speex_header(AVFormatContext *s, int idx) {
    struct ogg *ogg = s->priv_data;
    struct ogg_stream *os = ogg->streams + idx;
    AVStream *st = s->streams[idx];
    uint8_t *p = os->buf + os->pstart;
    if (os->seq > 1)
        return 0;
    if (os->seq == 0) {
        st->codec->codec_type = CODEC_TYPE_AUDIO;
        st->codec->codec_id = CODEC_ID_SPEEX;
        st->codec->sample_rate = AV_RL32(p + 36);
        st->codec->channels = AV_RL32(p + 48);
        st->codec->frame_size = AV_RL32(p + 56);
        st->codec->extradata_size = os->psize;
        st->codec->extradata = av_malloc(st->codec->extradata_size);
        memcpy(st->codec->extradata, p, st->codec->extradata_size);
        st->time_base.num = 1;
        st->time_base.den = st->codec->sample_rate;
    } else
        vorbis_comment(s, p, os->psize);
    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    AVStream *st = s->streams[idx];\n    uint8_t *p = os->buf + os->pstart;\n    if (os->seq > 1)\n        return 0;\n    if (os->seq == 0) {\n        st->codec->codec_type = CODEC_TYPE_AUDIO;\n        st->codec->codec_id = CODEC_ID_SPEEX;\n        st->codec->sample_rate = AV_RL32(p + 36);\n        st->codec->channels = AV_RL32(p + 48);\n        st->codec->frame_size = AV_RL32(p + 56);\n        st->codec->extradata_size = os->psize;\n        st->codec->extradata = av_malloc(st->codec->extradata_size);\n        memcpy(st->codec->extradata, p, st->codec->extradata_size);\n        st->time_base.num = 1;\n        st->time_base.den = st->codec->sample_rate;\n    } else\n        vorbis_comment(s, p, os->psize);\n    return 1;\n}', 'void *av_malloc(unsigned int 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}']