libavcodec/ac3_parser.c:47: error: Null Dereference
  pointer `&gbc->buffer` last assigned on line 45 could be null and is dereferenced by call to `get_bits()` at line 47, column 22.

libavcodec/ac3_parser.c:37:1: start of procedure ff_ac3_parse_header()
35. 
36. 
37. int ff_ac3_parse_header(const uint8_t buf[7], AC3HeaderInfo *hdr)
    ^
38. {
39.     GetBitContext gbc;

libavcodec/ac3_parser.c:43:5: 
41.     int num_blocks;
42. 
43.     memset(hdr, 0, sizeof(*hdr));
        ^
44. 
45.     init_get_bits(&gbc, buf, 54);

libavcodec/ac3_parser.c:45:5: 
43.     memset(hdr, 0, sizeof(*hdr));
44. 
45.     init_get_bits(&gbc, buf, 54);
        ^
46. 
47.     hdr->sync_word = get_bits(&gbc, 16);

libavcodec/bitstream.h:758:1: start of procedure init_get_bits()
  756.  * @param bit_size the size of the buffer in bits
  757.  */
  758. static inline void init_get_bits(GetBitContext *s,
       ^
  759.                    const uint8_t *buffer, int bit_size)
  760. {

libavcodec/bitstream.h:761:5: 
  759.                    const uint8_t *buffer, int bit_size)
  760. {
  761.     int buffer_size= (bit_size+7)>>3;
           ^
  762.     if(buffer_size < 0 || bit_size < 0) {
  763.         buffer_size = bit_size = 0;

libavcodec/bitstream.h:762:8: Taking true branch
  760. {
  761.     int buffer_size= (bit_size+7)>>3;
  762.     if(buffer_size < 0 || bit_size < 0) {
              ^
  763.         buffer_size = bit_size = 0;
  764.         buffer = NULL;

libavcodec/bitstream.h:763:9: 
  761.     int buffer_size= (bit_size+7)>>3;
  762.     if(buffer_size < 0 || bit_size < 0) {
  763.         buffer_size = bit_size = 0;
               ^
  764.         buffer = NULL;
  765.     }

libavcodec/bitstream.h:764:9: 
  762.     if(buffer_size < 0 || bit_size < 0) {
  763.         buffer_size = bit_size = 0;
  764.         buffer = NULL;
               ^
  765.     }
  766. 

libavcodec/bitstream.h:767:5: 
  765.     }
  766. 
  767.     s->buffer= buffer;
           ^
  768.     s->size_in_bits= bit_size;
  769.     s->buffer_end= buffer + buffer_size;

libavcodec/bitstream.h:768:5: 
  766. 
  767.     s->buffer= buffer;
  768.     s->size_in_bits= bit_size;
           ^
  769.     s->buffer_end= buffer + buffer_size;
  770. #ifdef ALT_BITSTREAM_READER

libavcodec/bitstream.h:769:5: 
  767.     s->buffer= buffer;
  768.     s->size_in_bits= bit_size;
  769.     s->buffer_end= buffer + buffer_size;
           ^
  770. #ifdef ALT_BITSTREAM_READER
  771.     s->index=0;

libavcodec/bitstream.h:771:5: 
  769.     s->buffer_end= buffer + buffer_size;
  770. #ifdef ALT_BITSTREAM_READER
  771.     s->index=0;
           ^
  772. #elif defined LIBMPEG2_BITSTREAM_READER
  773.     s->buffer_ptr = (uint8_t*)((intptr_t)buffer&(~1));

libavcodec/bitstream.h:781:1: return from a call to init_get_bits
  779.     skip_bits_long(s, 0);
  780. #endif
  781. }
       ^
  782. 
  783. static inline void align_get_bits(GetBitContext *s)

libavcodec/ac3_parser.c:47:5: 
45.     init_get_bits(&gbc, buf, 54);
46. 
47.     hdr->sync_word = get_bits(&gbc, 16);
        ^
48.     if(hdr->sync_word != 0x0B77)
49.         return AC3_PARSE_ERROR_SYNC;

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

libavcodec/bitstream.h:657:5: 
  655. static inline unsigned int get_bits(GetBitContext *s, int n){
  656.     register int tmp;
  657.     OPEN_READER(re, s)
           ^
  658.     UPDATE_CACHE(re, s)
  659.     tmp= SHOW_UBITS(re, s, n);

libavcodec/bitstream.h:658:5: 
  656.     register int tmp;
  657.     OPEN_READER(re, s)
  658.     UPDATE_CACHE(re, s)
           ^
  659.     tmp= SHOW_UBITS(re, s, n);
  660.     LAST_SKIP_BITS(re, s, n)

int ff_ac3_parse_header(const uint8_t buf[7], AC3HeaderInfo *hdr)
{
    GetBitContext gbc;
    int frame_size_code;
    int num_blocks;
    memset(hdr, 0, sizeof(*hdr));
    init_get_bits(&gbc, buf, 54);
    hdr->sync_word = get_bits(&gbc, 16);
    if(hdr->sync_word != 0x0B77)
        return AC3_PARSE_ERROR_SYNC;
    hdr->bitstream_id = show_bits_long(&gbc, 29) & 0x1F;
    if(hdr->bitstream_id > 16)
        return AC3_PARSE_ERROR_BSID;
    if(hdr->bitstream_id <= 10) {
        hdr->crc1 = get_bits(&gbc, 16);
        hdr->sr_code = get_bits(&gbc, 2);
        if(hdr->sr_code == 3)
            return AC3_PARSE_ERROR_SAMPLE_RATE;
        frame_size_code = get_bits(&gbc, 6);
        if(frame_size_code > 37)
            return AC3_PARSE_ERROR_FRAME_SIZE;
        skip_bits(&gbc, 5);
        skip_bits(&gbc, 3);
        hdr->channel_mode = get_bits(&gbc, 3);
        if((hdr->channel_mode & 1) && hdr->channel_mode != AC3_CHMODE_MONO) {
            skip_bits(&gbc, 2);
        }
        if(hdr->channel_mode & 4) {
            skip_bits(&gbc, 2);
        }
        if(hdr->channel_mode == AC3_CHMODE_STEREO) {
            skip_bits(&gbc, 2);
        }
        hdr->lfe_on = get_bits1(&gbc);
        hdr->sr_shift = FFMAX(hdr->bitstream_id, 8) - 8;
        hdr->sample_rate = ff_ac3_sample_rate_tab[hdr->sr_code] >> hdr->sr_shift;
        hdr->bit_rate = (ff_ac3_bitrate_tab[frame_size_code>>1] * 1000) >> hdr->sr_shift;
        hdr->channels = ff_ac3_channels_tab[hdr->channel_mode] + hdr->lfe_on;
        hdr->frame_size = ff_ac3_frame_size_tab[frame_size_code][hdr->sr_code] * 2;
        hdr->frame_type = EAC3_FRAME_TYPE_INDEPENDENT;
    } else {
        hdr->crc1 = 0;
        hdr->frame_type = get_bits(&gbc, 2);
        if(hdr->frame_type == EAC3_FRAME_TYPE_RESERVED)
            return AC3_PARSE_ERROR_FRAME_TYPE;
        skip_bits(&gbc, 3);
        hdr->frame_size = (get_bits(&gbc, 11) + 1) << 1;
        if(hdr->frame_size < AC3_HEADER_SIZE)
            return AC3_PARSE_ERROR_FRAME_SIZE;
        hdr->sr_code = get_bits(&gbc, 2);
        if (hdr->sr_code == 3) {
            int sr_code2 = get_bits(&gbc, 2);
            if(sr_code2 == 3)
                return AC3_PARSE_ERROR_SAMPLE_RATE;
            hdr->sample_rate = ff_ac3_sample_rate_tab[sr_code2] / 2;
            hdr->sr_shift = 1;
            num_blocks = 6;
        } else {
            num_blocks = eac3_blocks[get_bits(&gbc, 2)];
            hdr->sample_rate = ff_ac3_sample_rate_tab[hdr->sr_code];
            hdr->sr_shift = 0;
        }
        hdr->channel_mode = get_bits(&gbc, 3);
        hdr->lfe_on = get_bits1(&gbc);
        hdr->bit_rate = (uint32_t)(8.0 * hdr->frame_size * hdr->sample_rate /
                        (num_blocks * 256.0));
        hdr->channels = ff_ac3_channels_tab[hdr->channel_mode] + hdr->lfe_on;
    }
    return 0;
}
['int ff_ac3_parse_header(const uint8_t buf[7], AC3HeaderInfo *hdr)\n{\n    GetBitContext gbc;\n    int frame_size_code;\n    int num_blocks;\n    memset(hdr, 0, sizeof(*hdr));\n    init_get_bits(&gbc, buf, 54);\n    hdr->sync_word = get_bits(&gbc, 16);\n    if(hdr->sync_word != 0x0B77)\n        return AC3_PARSE_ERROR_SYNC;\n    hdr->bitstream_id = show_bits_long(&gbc, 29) & 0x1F;\n    if(hdr->bitstream_id > 16)\n        return AC3_PARSE_ERROR_BSID;\n    if(hdr->bitstream_id <= 10) {\n        hdr->crc1 = get_bits(&gbc, 16);\n        hdr->sr_code = get_bits(&gbc, 2);\n        if(hdr->sr_code == 3)\n            return AC3_PARSE_ERROR_SAMPLE_RATE;\n        frame_size_code = get_bits(&gbc, 6);\n        if(frame_size_code > 37)\n            return AC3_PARSE_ERROR_FRAME_SIZE;\n        skip_bits(&gbc, 5);\n        skip_bits(&gbc, 3);\n        hdr->channel_mode = get_bits(&gbc, 3);\n        if((hdr->channel_mode & 1) && hdr->channel_mode != AC3_CHMODE_MONO) {\n            skip_bits(&gbc, 2);\n        }\n        if(hdr->channel_mode & 4) {\n            skip_bits(&gbc, 2);\n        }\n        if(hdr->channel_mode == AC3_CHMODE_STEREO) {\n            skip_bits(&gbc, 2);\n        }\n        hdr->lfe_on = get_bits1(&gbc);\n        hdr->sr_shift = FFMAX(hdr->bitstream_id, 8) - 8;\n        hdr->sample_rate = ff_ac3_sample_rate_tab[hdr->sr_code] >> hdr->sr_shift;\n        hdr->bit_rate = (ff_ac3_bitrate_tab[frame_size_code>>1] * 1000) >> hdr->sr_shift;\n        hdr->channels = ff_ac3_channels_tab[hdr->channel_mode] + hdr->lfe_on;\n        hdr->frame_size = ff_ac3_frame_size_tab[frame_size_code][hdr->sr_code] * 2;\n        hdr->frame_type = EAC3_FRAME_TYPE_INDEPENDENT;\n    } else {\n        hdr->crc1 = 0;\n        hdr->frame_type = get_bits(&gbc, 2);\n        if(hdr->frame_type == EAC3_FRAME_TYPE_RESERVED)\n            return AC3_PARSE_ERROR_FRAME_TYPE;\n        skip_bits(&gbc, 3);\n        hdr->frame_size = (get_bits(&gbc, 11) + 1) << 1;\n        if(hdr->frame_size < AC3_HEADER_SIZE)\n            return AC3_PARSE_ERROR_FRAME_SIZE;\n        hdr->sr_code = get_bits(&gbc, 2);\n        if (hdr->sr_code == 3) {\n            int sr_code2 = get_bits(&gbc, 2);\n            if(sr_code2 == 3)\n                return AC3_PARSE_ERROR_SAMPLE_RATE;\n            hdr->sample_rate = ff_ac3_sample_rate_tab[sr_code2] / 2;\n            hdr->sr_shift = 1;\n            num_blocks = 6;\n        } else {\n            num_blocks = eac3_blocks[get_bits(&gbc, 2)];\n            hdr->sample_rate = ff_ac3_sample_rate_tab[hdr->sr_code];\n            hdr->sr_shift = 0;\n        }\n        hdr->channel_mode = get_bits(&gbc, 3);\n        hdr->lfe_on = get_bits1(&gbc);\n        hdr->bit_rate = (uint32_t)(8.0 * hdr->frame_size * hdr->sample_rate /\n                        (num_blocks * 256.0));\n        hdr->channels = ff_ac3_channels_tab[hdr->channel_mode] + hdr->lfe_on;\n    }\n    return 0;\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}']