libavformat/mpegts.c:686: error: Null Dereference
  pointer `&gb->buffer` last assigned on line 683 could be null and is dereferenced by call to `get_bits1()` at line 686, column 25.

libavformat/mpegts.c:676:1: start of procedure read_sl_header()
674. }
675. 
676. static int read_sl_header(PESContext *pes, SLConfigDescr *sl, const uint8_t *buf, int buf_size)
     ^
677. {
678.     GetBitContext gb;

libavformat/mpegts.c:679:5: 
677. {
678.     GetBitContext gb;
679.     int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0;
         ^
680.     int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;
681.     int dts_flag = -1, cts_flag = -1;

libavformat/mpegts.c:680:5: 
678.     GetBitContext gb;
679.     int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0;
680.     int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;
         ^
681.     int dts_flag = -1, cts_flag = -1;
682.     int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE;

libavformat/mpegts.c:681:5: 
679.     int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0;
680.     int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;
681.     int dts_flag = -1, cts_flag = -1;
         ^
682.     int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE;
683.     init_get_bits(&gb, buf, buf_size*8);

libavformat/mpegts.c:682:5: 
680.     int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;
681.     int dts_flag = -1, cts_flag = -1;
682.     int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE;
         ^
683.     init_get_bits(&gb, buf, buf_size*8);
684. 

libavformat/mpegts.c:683:5: 
681.     int dts_flag = -1, cts_flag = -1;
682.     int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE;
683.     init_get_bits(&gb, buf, buf_size*8);
         ^
684. 
685.     if (sl->use_au_start)

libavcodec/get_bits.h:306:1: start of procedure init_get_bits()
  304.  * responsible for checking for the buffer end yourself (take advantage of the padding)!
  305.  */
  306. static inline void init_get_bits(GetBitContext *s,
       ^
  307.                    const uint8_t *buffer, int bit_size)
  308. {

libavcodec/get_bits.h:309:5: 
  307.                    const uint8_t *buffer, int bit_size)
  308. {
  309.     int buffer_size = (bit_size+7)>>3;
           ^
  310.     if (buffer_size < 0 || bit_size < 0) {
  311.         buffer_size = bit_size = 0;

libavcodec/get_bits.h:310:9: Taking true branch
  308. {
  309.     int buffer_size = (bit_size+7)>>3;
  310.     if (buffer_size < 0 || bit_size < 0) {
               ^
  311.         buffer_size = bit_size = 0;
  312.         buffer = NULL;

libavcodec/get_bits.h:311:9: 
  309.     int buffer_size = (bit_size+7)>>3;
  310.     if (buffer_size < 0 || bit_size < 0) {
  311.         buffer_size = bit_size = 0;
               ^
  312.         buffer = NULL;
  313.     }

libavcodec/get_bits.h:312:9: 
  310.     if (buffer_size < 0 || bit_size < 0) {
  311.         buffer_size = bit_size = 0;
  312.         buffer = NULL;
               ^
  313.     }
  314. 

libavcodec/get_bits.h:315:5: 
  313.     }
  314. 
  315.     s->buffer       = buffer;
           ^
  316.     s->size_in_bits = bit_size;
  317.     s->buffer_end   = buffer + buffer_size;

libavcodec/get_bits.h:316:5: 
  314. 
  315.     s->buffer       = buffer;
  316.     s->size_in_bits = bit_size;
           ^
  317.     s->buffer_end   = buffer + buffer_size;
  318.     s->index        = 0;

libavcodec/get_bits.h:317:5: 
  315.     s->buffer       = buffer;
  316.     s->size_in_bits = bit_size;
  317.     s->buffer_end   = buffer + buffer_size;
           ^
  318.     s->index        = 0;
  319. }

libavcodec/get_bits.h:318:5: 
  316.     s->size_in_bits = bit_size;
  317.     s->buffer_end   = buffer + buffer_size;
  318.     s->index        = 0;
           ^
  319. }
  320. 

libavcodec/get_bits.h:319:1: return from a call to init_get_bits
  317.     s->buffer_end   = buffer + buffer_size;
  318.     s->index        = 0;
  319. }
       ^
  320. 
  321. static inline void align_get_bits(GetBitContext *s)

libavformat/mpegts.c:685:9: Taking true branch
683.     init_get_bits(&gb, buf, buf_size*8);
684. 
685.     if (sl->use_au_start)
             ^
686.         au_start_flag = get_bits1(&gb);
687.     if (sl->use_au_end)

libavformat/mpegts.c:686:9: 
684. 
685.     if (sl->use_au_start)
686.         au_start_flag = get_bits1(&gb);
             ^
687.     if (sl->use_au_end)
688.         au_end_flag = get_bits1(&gb);

libavcodec/get_bits.h:230:1: start of procedure get_bits1()
  228. }
  229. 
  230. static inline unsigned int get_bits1(GetBitContext *s){
       ^
  231.     unsigned int index = s->index;
  232.     uint8_t result = s->buffer[index>>3];

libavcodec/get_bits.h:231:5: 
  229. 
  230. static inline unsigned int get_bits1(GetBitContext *s){
  231.     unsigned int index = s->index;
           ^
  232.     uint8_t result = s->buffer[index>>3];
  233. #ifdef ALT_BITSTREAM_READER_LE

libavcodec/get_bits.h:232:5: 
  230. static inline unsigned int get_bits1(GetBitContext *s){
  231.     unsigned int index = s->index;
  232.     uint8_t result = s->buffer[index>>3];
           ^
  233. #ifdef ALT_BITSTREAM_READER_LE
  234.     result >>= index & 7;

static int read_sl_header(PESContext *pes, SLConfigDescr *sl, const uint8_t *buf, int buf_size)
{
    GetBitContext gb;
    int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0;
    int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;
    int dts_flag = -1, cts_flag = -1;
    int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE;
    init_get_bits(&gb, buf, buf_size*8);
    if (sl->use_au_start)
        au_start_flag = get_bits1(&gb);
    if (sl->use_au_end)
        au_end_flag = get_bits1(&gb);
    if (!sl->use_au_start && !sl->use_au_end)
        au_start_flag = au_end_flag = 1;
    if (sl->ocr_len > 0)
        ocr_flag = get_bits1(&gb);
    if (sl->use_idle)
        idle_flag = get_bits1(&gb);
    if (sl->use_padding)
        padding_flag = get_bits1(&gb);
    if (padding_flag)
        padding_bits = get_bits(&gb, 3);
    if (!idle_flag && (!padding_flag || padding_bits != 0)) {
        if (sl->packet_seq_num_len)
            skip_bits_long(&gb, sl->packet_seq_num_len);
        if (sl->degr_prior_len)
            if (get_bits1(&gb))
                skip_bits(&gb, sl->degr_prior_len);
        if (ocr_flag)
            skip_bits_long(&gb, sl->ocr_len);
        if (au_start_flag) {
            if (sl->use_rand_acc_pt)
                get_bits1(&gb);
            if (sl->au_seq_num_len > 0)
                skip_bits_long(&gb, sl->au_seq_num_len);
            if (sl->use_timestamps) {
                dts_flag = get_bits1(&gb);
                cts_flag = get_bits1(&gb);
            }
        }
        if (sl->inst_bitrate_len)
            inst_bitrate_flag = get_bits1(&gb);
        if (dts_flag == 1)
            dts = get_bits64(&gb, sl->timestamp_len);
        if (cts_flag == 1)
            cts = get_bits64(&gb, sl->timestamp_len);
        if (sl->au_len > 0)
            skip_bits_long(&gb, sl->au_len);
        if (inst_bitrate_flag)
            skip_bits_long(&gb, sl->inst_bitrate_len);
    }
    if (dts != AV_NOPTS_VALUE)
        pes->dts = dts;
    if (cts != AV_NOPTS_VALUE)
        pes->pts = cts;
    avpriv_set_pts_info(pes->st, sl->timestamp_len, 1, sl->timestamp_res);
    return (get_bits_count(&gb) + 7) >> 3;
}
['static int read_sl_header(PESContext *pes, SLConfigDescr *sl, const uint8_t *buf, int buf_size)\n{\n    GetBitContext gb;\n    int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0;\n    int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;\n    int dts_flag = -1, cts_flag = -1;\n    int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE;\n    init_get_bits(&gb, buf, buf_size*8);\n    if (sl->use_au_start)\n        au_start_flag = get_bits1(&gb);\n    if (sl->use_au_end)\n        au_end_flag = get_bits1(&gb);\n    if (!sl->use_au_start && !sl->use_au_end)\n        au_start_flag = au_end_flag = 1;\n    if (sl->ocr_len > 0)\n        ocr_flag = get_bits1(&gb);\n    if (sl->use_idle)\n        idle_flag = get_bits1(&gb);\n    if (sl->use_padding)\n        padding_flag = get_bits1(&gb);\n    if (padding_flag)\n        padding_bits = get_bits(&gb, 3);\n    if (!idle_flag && (!padding_flag || padding_bits != 0)) {\n        if (sl->packet_seq_num_len)\n            skip_bits_long(&gb, sl->packet_seq_num_len);\n        if (sl->degr_prior_len)\n            if (get_bits1(&gb))\n                skip_bits(&gb, sl->degr_prior_len);\n        if (ocr_flag)\n            skip_bits_long(&gb, sl->ocr_len);\n        if (au_start_flag) {\n            if (sl->use_rand_acc_pt)\n                get_bits1(&gb);\n            if (sl->au_seq_num_len > 0)\n                skip_bits_long(&gb, sl->au_seq_num_len);\n            if (sl->use_timestamps) {\n                dts_flag = get_bits1(&gb);\n                cts_flag = get_bits1(&gb);\n            }\n        }\n        if (sl->inst_bitrate_len)\n            inst_bitrate_flag = get_bits1(&gb);\n        if (dts_flag == 1)\n            dts = get_bits64(&gb, sl->timestamp_len);\n        if (cts_flag == 1)\n            cts = get_bits64(&gb, sl->timestamp_len);\n        if (sl->au_len > 0)\n            skip_bits_long(&gb, sl->au_len);\n        if (inst_bitrate_flag)\n            skip_bits_long(&gb, sl->inst_bitrate_len);\n    }\n    if (dts != AV_NOPTS_VALUE)\n        pes->dts = dts;\n    if (cts != AV_NOPTS_VALUE)\n        pes->pts = cts;\n    avpriv_set_pts_info(pes->st, sl->timestamp_len, 1, sl->timestamp_res);\n    return (get_bits_count(&gb) + 7) >> 3;\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    s->index        = 0;\n}', 'static inline unsigned int get_bits1(GetBitContext *s){\n    unsigned int index = s->index;\n    uint8_t result = s->buffer[index>>3];\n#ifdef ALT_BITSTREAM_READER_LE\n    result >>= index & 7;\n    result &= 1;\n#else\n    result <<= index & 7;\n    result >>= 8 - 1;\n#endif\n    index++;\n    s->index = index;\n    return result;\n}']