libavformat/oggparseflac.c:41: error: Null Dereference
  pointer `&gb->buffer` last assigned on line 40 could be null and is dereferenced by call to `get_bits()` at line 41, column 5.

libavformat/oggparseflac.c:28:1: start of procedure flac_header()
26. #define FLAC_STREAMINFO_SIZE 0x22
27. 
28. static int
    ^
29. flac_header (AVFormatContext * s, int idx)
30. {

libavformat/oggparseflac.c:31:5: 
29. flac_header (AVFormatContext * s, int idx)
30. {
31.     struct ogg *ogg = s->priv_data;
        ^
32.     struct ogg_stream *os = ogg->streams + idx;
33.     AVStream *st = s->streams[idx];

libavformat/oggparseflac.c:32:5: 
30. {
31.     struct ogg *ogg = s->priv_data;
32.     struct ogg_stream *os = ogg->streams + idx;
        ^
33.     AVStream *st = s->streams[idx];
34.     GetBitContext gb;

libavformat/oggparseflac.c:33:5: 
31.     struct ogg *ogg = s->priv_data;
32.     struct ogg_stream *os = ogg->streams + idx;
33.     AVStream *st = s->streams[idx];
        ^
34.     GetBitContext gb;
35.     int mdt;

libavformat/oggparseflac.c:37:9: Taking false branch
35.     int mdt;
36. 
37.     if (os->buf[os->pstart] == 0xff)
            ^
38.         return 0;
39. 

libavformat/oggparseflac.c:40:5: 
38.         return 0;
39. 
40.     init_get_bits(&gb, os->buf + os->pstart, os->psize*8);
        ^
41.     get_bits(&gb, 1); /* metadata_last */
42.     mdt = get_bits(&gb, 7);

libavcodec/bitstream.h:745:1: start of procedure init_get_bits()
  743.  * @param bit_size the size of the buffer in bits
  744.  */
  745. static inline void init_get_bits(GetBitContext *s,
       ^
  746.                    const uint8_t *buffer, int bit_size)
  747. {

libavcodec/bitstream.h:748:5: 
  746.                    const uint8_t *buffer, int bit_size)
  747. {
  748.     int buffer_size= (bit_size+7)>>3;
           ^
  749.     if(buffer_size < 0 || bit_size < 0) {
  750.         buffer_size = bit_size = 0;

libavcodec/bitstream.h:749:8: Taking true branch
  747. {
  748.     int buffer_size= (bit_size+7)>>3;
  749.     if(buffer_size < 0 || bit_size < 0) {
              ^
  750.         buffer_size = bit_size = 0;
  751.         buffer = NULL;

libavcodec/bitstream.h:750:9: 
  748.     int buffer_size= (bit_size+7)>>3;
  749.     if(buffer_size < 0 || bit_size < 0) {
  750.         buffer_size = bit_size = 0;
               ^
  751.         buffer = NULL;
  752.     }

libavcodec/bitstream.h:751:9: 
  749.     if(buffer_size < 0 || bit_size < 0) {
  750.         buffer_size = bit_size = 0;
  751.         buffer = NULL;
               ^
  752.     }
  753. 

libavcodec/bitstream.h:754:5: 
  752.     }
  753. 
  754.     s->buffer= buffer;
           ^
  755.     s->size_in_bits= bit_size;
  756.     s->buffer_end= buffer + buffer_size;

libavcodec/bitstream.h:755:5: 
  753. 
  754.     s->buffer= buffer;
  755.     s->size_in_bits= bit_size;
           ^
  756.     s->buffer_end= buffer + buffer_size;
  757. #ifdef ALT_BITSTREAM_READER

libavcodec/bitstream.h:756:5: 
  754.     s->buffer= buffer;
  755.     s->size_in_bits= bit_size;
  756.     s->buffer_end= buffer + buffer_size;
           ^
  757. #ifdef ALT_BITSTREAM_READER
  758.     s->index=0;

libavcodec/bitstream.h:758:5: 
  756.     s->buffer_end= buffer + buffer_size;
  757. #ifdef ALT_BITSTREAM_READER
  758.     s->index=0;
           ^
  759. #elif defined LIBMPEG2_BITSTREAM_READER
  760.     s->buffer_ptr = (uint8_t*)((intptr_t)buffer&(~1));

libavcodec/bitstream.h:768:1: return from a call to init_get_bits
  766.     skip_bits_long(s, 0);
  767. #endif
  768. }
       ^
  769. 
  770. static inline void align_get_bits(GetBitContext *s)

libavformat/oggparseflac.c:41:5: 
39. 
40.     init_get_bits(&gb, os->buf + os->pstart, os->psize*8);
41.     get_bits(&gb, 1); /* metadata_last */
        ^
42.     mdt = get_bits(&gb, 7);
43. 

libavcodec/bitstream.h:642:1: start of procedure get_bits()
  640.  * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't
  641.  */
  642. static inline unsigned int get_bits(GetBitContext *s, int n){
       ^
  643.     register int tmp;
  644.     OPEN_READER(re, s)

libavcodec/bitstream.h:644:5: 
  642. static inline unsigned int get_bits(GetBitContext *s, int n){
  643.     register int tmp;
  644.     OPEN_READER(re, s)
           ^
  645.     UPDATE_CACHE(re, s)
  646.     tmp= SHOW_UBITS(re, s, n);

libavcodec/bitstream.h:645:5: 
  643.     register int tmp;
  644.     OPEN_READER(re, s)
  645.     UPDATE_CACHE(re, s)
           ^
  646.     tmp= SHOW_UBITS(re, s, n);
  647.     LAST_SKIP_BITS(re, s, n)

static int
flac_header (AVFormatContext * s, int idx)
{
    struct ogg *ogg = s->priv_data;
    struct ogg_stream *os = ogg->streams + idx;
    AVStream *st = s->streams[idx];
    GetBitContext gb;
    int mdt;
    if (os->buf[os->pstart] == 0xff)
        return 0;
    init_get_bits(&gb, os->buf + os->pstart, os->psize*8);
    get_bits(&gb, 1);
    mdt = get_bits(&gb, 7);
    if (mdt == 0x7f) {
        skip_bits(&gb, 4*8);
        if(get_bits(&gb, 8) != 1)
            return -1;
        skip_bits(&gb, 8 + 16);
        skip_bits(&gb, 4*8);
        if (get_bits_long(&gb, 32) != FLAC_STREAMINFO_SIZE)
            return -1;
        skip_bits(&gb, 16*2+24*2);
        st->codec->sample_rate = get_bits_long(&gb, 20);
        st->codec->channels = get_bits(&gb, 3) + 1;
        st->codec->codec_type = CODEC_TYPE_AUDIO;
        st->codec->codec_id = CODEC_ID_FLAC;
        st->codec->extradata =
            av_malloc(FLAC_STREAMINFO_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
        memcpy (st->codec->extradata, os->buf + os->pstart + 5 + 4 + 4 + 4,
                FLAC_STREAMINFO_SIZE);
        st->codec->extradata_size = FLAC_STREAMINFO_SIZE;
        st->time_base.num = 1;
        st->time_base.den = st->codec->sample_rate;
    } else if (mdt == 4) {
        vorbis_comment (s, os->buf + os->pstart + 4, os->psize - 4);
    }
    return 1;
}
['static int\nflac_header (AVFormatContext * s, int idx)\n{\n    struct ogg *ogg = s->priv_data;\n    struct ogg_stream *os = ogg->streams + idx;\n    AVStream *st = s->streams[idx];\n    GetBitContext gb;\n    int mdt;\n    if (os->buf[os->pstart] == 0xff)\n        return 0;\n    init_get_bits(&gb, os->buf + os->pstart, os->psize*8);\n    get_bits(&gb, 1);\n    mdt = get_bits(&gb, 7);\n    if (mdt == 0x7f) {\n        skip_bits(&gb, 4*8);\n        if(get_bits(&gb, 8) != 1)\n            return -1;\n        skip_bits(&gb, 8 + 16);\n        skip_bits(&gb, 4*8);\n        if (get_bits_long(&gb, 32) != FLAC_STREAMINFO_SIZE)\n            return -1;\n        skip_bits(&gb, 16*2+24*2);\n        st->codec->sample_rate = get_bits_long(&gb, 20);\n        st->codec->channels = get_bits(&gb, 3) + 1;\n        st->codec->codec_type = CODEC_TYPE_AUDIO;\n        st->codec->codec_id = CODEC_ID_FLAC;\n        st->codec->extradata =\n            av_malloc(FLAC_STREAMINFO_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);\n        memcpy (st->codec->extradata, os->buf + os->pstart + 5 + 4 + 4 + 4,\n                FLAC_STREAMINFO_SIZE);\n        st->codec->extradata_size = FLAC_STREAMINFO_SIZE;\n        st->time_base.num = 1;\n        st->time_base.den = st->codec->sample_rate;\n    } else if (mdt == 4) {\n        vorbis_comment (s, os->buf + os->pstart + 4, os->psize - 4);\n    }\n    return 1;\n}', 'static inline void init_get_bits(GetBitContext *s,\n                   const uint8_t *buffer, int bit_size)\n{\n    int buffer_size= (bit_size+7)>>3;\n    if(buffer_size < 0 || bit_size < 0) {\n        buffer_size = bit_size = 0;\n        buffer = NULL;\n    }\n    s->buffer= buffer;\n    s->size_in_bits= bit_size;\n    s->buffer_end= buffer + buffer_size;\n#ifdef ALT_BITSTREAM_READER\n    s->index=0;\n#elif defined LIBMPEG2_BITSTREAM_READER\n    s->buffer_ptr = (uint8_t*)((intptr_t)buffer&(~1));\n    s->bit_count = 16 + 8*((intptr_t)buffer&1);\n    skip_bits_long(s, 0);\n#elif defined A32_BITSTREAM_READER\n    s->buffer_ptr = (uint32_t*)((intptr_t)buffer&(~3));\n    s->bit_count = 32 + 8*((intptr_t)buffer&3);\n    skip_bits_long(s, 0);\n#endif\n}', 'static inline unsigned int get_bits(GetBitContext *s, int n){\n    register int tmp;\n    OPEN_READER(re, s)\n    UPDATE_CACHE(re, s)\n    tmp= SHOW_UBITS(re, s, n);\n    LAST_SKIP_BITS(re, s, n)\n    CLOSE_READER(re, s)\n    return tmp;\n}']