libavformat/oggdec.c:65: error: Null Dereference
  pointer `ost` last assigned on line 62 could be null and is dereferenced at line 65, column 5.

libavformat/oggdec.c:58:1: start of procedure ogg_save()
56. 
57. //FIXME We could avoid some structure duplication
58. static int
    ^
59. ogg_save (AVFormatContext * s)
60. {

libavformat/oggdec.c:61:5: 
59. ogg_save (AVFormatContext * s)
60. {
61.     struct ogg *ogg = s->priv_data;
        ^
62.     struct ogg_state *ost =
63.         av_malloc(sizeof (*ost) + (ogg->nstreams-1) * sizeof (*ogg->streams));

libavformat/oggdec.c:62:5: 
60. {
61.     struct ogg *ogg = s->priv_data;
62.     struct ogg_state *ost =
        ^
63.         av_malloc(sizeof (*ost) + (ogg->nstreams-1) * sizeof (*ogg->streams));
64.     int i;

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

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

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

libavutil/mem.c:83:9: Taking true branch
  81.     ((char*)ptr)[-1]= diff;
  82. #elif HAVE_POSIX_MEMALIGN
  83.     if (posix_memalign(&ptr,16,size))
              ^
  84.         ptr = NULL;
  85. #elif HAVE_MEMALIGN

libavutil/mem.c:84:9: 
  82. #elif HAVE_POSIX_MEMALIGN
  83.     if (posix_memalign(&ptr,16,size))
  84.         ptr = NULL;
              ^
  85. #elif HAVE_MEMALIGN
  86.     ptr = memalign(16,size);

libavutil/mem.c:116:5: 
  114.     ptr = malloc(size);
  115. #endif
  116.     return ptr;
           ^
  117. }
  118. 

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, FF_INTERNAL_MEM_TYPE size)

libavformat/oggdec.c:65:5: 
63.         av_malloc(sizeof (*ost) + (ogg->nstreams-1) * sizeof (*ogg->streams));
64.     int i;
65.     ost->pos = url_ftell (s->pb);
        ^
66.     ost->curidx = ogg->curidx;
67.     ost->next = ogg->state;

libavformat/aviobuf.c:200:1: start of procedure url_ftell()
  198. }
  199. 
  200. int64_t url_ftell(ByteIOContext *s)
       ^
  201. {
  202.     return url_fseek(s, 0, SEEK_CUR);

libavformat/aviobuf.c:202:5: Skipping url_fseek(): empty list of specs
  200. int64_t url_ftell(ByteIOContext *s)
  201. {
  202.     return url_fseek(s, 0, SEEK_CUR);
           ^
  203. }
  204. 

libavformat/aviobuf.c:203:1: return from a call to url_ftell
  201. {
  202.     return url_fseek(s, 0, SEEK_CUR);
  203. }
       ^
  204. 
  205. int64_t url_fsize(ByteIOContext *s)

static int
ogg_save (AVFormatContext * s)
{
    struct ogg *ogg = s->priv_data;
    struct ogg_state *ost =
        av_malloc(sizeof (*ost) + (ogg->nstreams-1) * sizeof (*ogg->streams));
    int i;
    ost->pos = url_ftell (s->pb);
    ost->curidx = ogg->curidx;
    ost->next = ogg->state;
    ost->nstreams = ogg->nstreams;
    memcpy(ost->streams, ogg->streams, ogg->nstreams * sizeof(*ogg->streams));
    for (i = 0; i < ogg->nstreams; i++){
        struct ogg_stream *os = ogg->streams + i;
        os->buf = av_malloc (os->bufsize);
        memset (os->buf, 0, os->bufsize);
        memcpy (os->buf, ost->streams[i].buf, os->bufpos);
    }
    ogg->state = ost;
    return 0;
}
['static int\nogg_save (AVFormatContext * s)\n{\n    struct ogg *ogg = s->priv_data;\n    struct ogg_state *ost =\n        av_malloc(sizeof (*ost) + (ogg->nstreams-1) * sizeof (*ogg->streams));\n    int i;\n    ost->pos = url_ftell (s->pb);\n    ost->curidx = ogg->curidx;\n    ost->next = ogg->state;\n    ost->nstreams = ogg->nstreams;\n    memcpy(ost->streams, ogg->streams, ogg->nstreams * sizeof(*ogg->streams));\n    for (i = 0; i < ogg->nstreams; i++){\n        struct ogg_stream *os = ogg->streams + i;\n        os->buf = av_malloc (os->bufsize);\n        memset (os->buf, 0, os->bufsize);\n        memcpy (os->buf, ost->streams[i].buf, os->bufpos);\n    }\n    ogg->state = ost;\n    return 0;\n}', 'void *av_malloc(FF_INTERNAL_MEM_TYPE 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}', 'int64_t url_ftell(ByteIOContext *s)\n{\n    return url_fseek(s, 0, SEEK_CUR);\n}']