libavformat/oggdec.c:184: error: Null Dereference
  pointer `nb` last assigned on line 181 could be null and is dereferenced by call to `memcpy()` at line 184, column 9.

libavformat/oggdec.c:177:1: start of procedure ogg_new_buf()
175. }
176. 
177. static int
     ^
178. ogg_new_buf(struct ogg *ogg, int idx)
179. {

libavformat/oggdec.c:180:5: 
178. ogg_new_buf(struct ogg *ogg, int idx)
179. {
180.     struct ogg_stream *os = ogg->streams + idx;
         ^
181.     uint8_t *nb = av_malloc(os->bufsize);
182.     int size = os->bufpos - os->pstart;

libavformat/oggdec.c:181:5: 
179. {
180.     struct ogg_stream *os = ogg->streams + idx;
181.     uint8_t *nb = av_malloc(os->bufsize);
         ^
182.     int size = os->bufpos - os->pstart;
183.     if(os->buf){

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: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, size_t size)

libavformat/oggdec.c:182:5: 
180.     struct ogg_stream *os = ogg->streams + idx;
181.     uint8_t *nb = av_malloc(os->bufsize);
182.     int size = os->bufpos - os->pstart;
         ^
183.     if(os->buf){
184.         memcpy(nb, os->buf + os->pstart, size);

libavformat/oggdec.c:183:8: Taking true branch
181.     uint8_t *nb = av_malloc(os->bufsize);
182.     int size = os->bufpos - os->pstart;
183.     if(os->buf){
            ^
184.         memcpy(nb, os->buf + os->pstart, size);
185.         av_free(os->buf);

libavformat/oggdec.c:184:9: 
182.     int size = os->bufpos - os->pstart;
183.     if(os->buf){
184.         memcpy(nb, os->buf + os->pstart, size);
             ^
185.         av_free(os->buf);
186.     }

static int
ogg_new_buf(struct ogg *ogg, int idx)
{
    struct ogg_stream *os = ogg->streams + idx;
    uint8_t *nb = av_malloc(os->bufsize);
    int size = os->bufpos - os->pstart;
    if(os->buf){
        memcpy(nb, os->buf + os->pstart, size);
        av_free(os->buf);
    }
    os->buf = nb;
    os->bufpos = size;
    os->pstart = 0;
    return 0;
}
['static int\nogg_new_buf(struct ogg *ogg, int idx)\n{\n    struct ogg_stream *os = ogg->streams + idx;\n    uint8_t *nb = av_malloc(os->bufsize);\n    int size = os->bufpos - os->pstart;\n    if(os->buf){\n        memcpy(nb, os->buf + os->pstart, size);\n        av_free(os->buf);\n    }\n    os->buf = nb;\n    os->bufpos = size;\n    os->pstart = 0;\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-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}']