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

libavformat/oggdec.c:61:1: start of procedure ogg_save()
59. 
60. //FIXME We could avoid some structure duplication
61. static int ogg_save(AVFormatContext *s)
    ^
62. {
63.     struct ogg *ogg = s->priv_data;

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

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

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

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

libavutil/mem.c:70:9: Taking false branch
  68. 
  69.     /* let's disallow possibly ambiguous cases */
  70.     if (size > (INT_MAX - 32) || !size)
              ^
  71.         return NULL;
  72. 

libavutil/mem.c:70:35: Taking false branch
  68. 
  69.     /* let's disallow possibly ambiguous cases */
  70.     if (size > (INT_MAX - 32) || !size)
                                        ^
  71.         return NULL;
  72. 

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

libavutil/mem.c:82:9: 
  80. #elif HAVE_POSIX_MEMALIGN
  81.     if (posix_memalign(&ptr, 32, size))
  82.         ptr = NULL;
              ^
  83. #elif HAVE_ALIGNED_MALLOC
  84.     ptr = _aligned_malloc(size, 32);

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

libavutil/mem.c:115:1: return from a call to av_malloc
  113. #endif
  114.     return ptr;
  115. }
       ^
  116. 
  117. void *av_realloc(void *ptr, size_t size)

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

libavformat/avio.h:219:1: start of procedure avio_tell()
  217.  * @return position or AVERROR.
  218.  */
  219. static av_always_inline int64_t avio_tell(AVIOContext *s)
       ^
  220. {
  221.     return avio_seek(s, 0, SEEK_CUR);

libavformat/avio.h:221:5: Skipping avio_seek(): empty list of specs
  219. static av_always_inline int64_t avio_tell(AVIOContext *s)
  220. {
  221.     return avio_seek(s, 0, SEEK_CUR);
           ^
  222. }
  223. 

libavformat/avio.h:222:1: return from a call to avio_tell
  220. {
  221.     return avio_seek(s, 0, SEEK_CUR);
  222. }
       ^
  223. 
  224. /**

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      = avio_tell(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_mallocz(os->bufsize + FF_INPUT_BUFFER_PADDING_SIZE);
        memcpy(os->buf, ost->streams[i].buf, os->bufpos);
    }
    ogg->state = ost;
    return 0;
}
['static int ogg_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      = avio_tell(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_mallocz(os->bufsize + FF_INPUT_BUFFER_PADDING_SIZE);\n        memcpy(os->buf, ost->streams[i].buf, os->bufpos);\n    }\n    ogg->state = ost;\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}', 'static av_always_inline int64_t avio_tell(AVIOContext *s)\n{\n    return avio_seek(s, 0, SEEK_CUR);\n}']