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

libavformat/mpegts.c:729:1: start of procedure read_sl_header()
727. }
728. 
729. static int read_sl_header(PESContext *pes, SLConfigDescr *sl,
     ^
730.                           const uint8_t *buf, int buf_size)
731. {

libavformat/mpegts.c:733:5: 
731. {
732.     GetBitContext gb;
733.     int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0;
         ^
734.     int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;
735.     int dts_flag = -1, cts_flag = -1;

libavformat/mpegts.c:734:5: 
732.     GetBitContext gb;
733.     int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0;
734.     int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;
         ^
735.     int dts_flag = -1, cts_flag = -1;
736.     int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE;

libavformat/mpegts.c:735:5: 
733.     int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0;
734.     int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;
735.     int dts_flag = -1, cts_flag = -1;
         ^
736.     int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE;
737.     init_get_bits(&gb, buf, buf_size * 8);

libavformat/mpegts.c:736:5: 
734.     int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;
735.     int dts_flag = -1, cts_flag = -1;
736.     int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE;
         ^
737.     init_get_bits(&gb, buf, buf_size * 8);
738. 

libavformat/mpegts.c:737:5: 
735.     int dts_flag = -1, cts_flag = -1;
736.     int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE;
737.     init_get_bits(&gb, buf, buf_size * 8);
         ^
738. 
739.     if (sl->use_au_start)

libavcodec/get_bits.h:376:1: start of procedure init_get_bits()
  374.  * @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow.
  375.  */
  376. static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,
       ^
  377.                                 int bit_size)
  378. {

libavcodec/get_bits.h:380:5: 
  378. {
  379.     int buffer_size;
  380.     int ret = 0;
           ^
  381. 
  382.     if (bit_size > INT_MAX - 7 || bit_size < 0 || !buffer) {

libavcodec/get_bits.h:382:9: Taking true branch
  380.     int ret = 0;
  381. 
  382.     if (bit_size > INT_MAX - 7 || bit_size < 0 || !buffer) {
               ^
  383.         bit_size    = 0;
  384.         buffer      = NULL;

libavcodec/get_bits.h:383:9: 
  381. 
  382.     if (bit_size > INT_MAX - 7 || bit_size < 0 || !buffer) {
  383.         bit_size    = 0;
               ^
  384.         buffer      = NULL;
  385.         ret         = AVERROR_INVALIDDATA;

libavcodec/get_bits.h:384:9: 
  382.     if (bit_size > INT_MAX - 7 || bit_size < 0 || !buffer) {
  383.         bit_size    = 0;
  384.         buffer      = NULL;
               ^
  385.         ret         = AVERROR_INVALIDDATA;
  386.     }

libavcodec/get_bits.h:385:9: 
  383.         bit_size    = 0;
  384.         buffer      = NULL;
  385.         ret         = AVERROR_INVALIDDATA;
               ^
  386.     }
  387. 

libavcodec/get_bits.h:388:5: 
  386.     }
  387. 
  388.     buffer_size = (bit_size + 7) >> 3;
           ^
  389. 
  390.     s->buffer             = buffer;

libavcodec/get_bits.h:390:5: 
  388.     buffer_size = (bit_size + 7) >> 3;
  389. 
  390.     s->buffer             = buffer;
           ^
  391.     s->size_in_bits       = bit_size;
  392. #if !UNCHECKED_BITSTREAM_READER

libavcodec/get_bits.h:391:5: 
  389. 
  390.     s->buffer             = buffer;
  391.     s->size_in_bits       = bit_size;
           ^
  392. #if !UNCHECKED_BITSTREAM_READER
  393.     s->size_in_bits_plus8 = bit_size + 8;

libavcodec/get_bits.h:393:5: 
  391.     s->size_in_bits       = bit_size;
  392. #if !UNCHECKED_BITSTREAM_READER
  393.     s->size_in_bits_plus8 = bit_size + 8;
           ^
  394. #endif
  395.     s->buffer_end         = buffer + buffer_size;

libavcodec/get_bits.h:395:5: 
  393.     s->size_in_bits_plus8 = bit_size + 8;
  394. #endif
  395.     s->buffer_end         = buffer + buffer_size;
           ^
  396.     s->index              = 0;
  397. 

libavcodec/get_bits.h:396:5: 
  394. #endif
  395.     s->buffer_end         = buffer + buffer_size;
  396.     s->index              = 0;
           ^
  397. 
  398.     return ret;

libavcodec/get_bits.h:398:5: 
  396.     s->index              = 0;
  397. 
  398.     return ret;
           ^
  399. }
  400. 

libavcodec/get_bits.h:399:1: return from a call to init_get_bits
  397. 
  398.     return ret;
  399. }
       ^
  400. 
  401. /**

libavformat/mpegts.c:739:9: Taking false branch
737.     init_get_bits(&gb, buf, buf_size * 8);
738. 
739.     if (sl->use_au_start)
             ^
740.         au_start_flag = get_bits1(&gb);
741.     if (sl->use_au_end)

libavformat/mpegts.c:741:9: Taking false branch
739.     if (sl->use_au_start)
740.         au_start_flag = get_bits1(&gb);
741.     if (sl->use_au_end)
             ^
742.         au_end_flag = get_bits1(&gb);
743.     if (!sl->use_au_start && !sl->use_au_end)

libavformat/mpegts.c:743:10: Taking true branch
741.     if (sl->use_au_end)
742.         au_end_flag = get_bits1(&gb);
743.     if (!sl->use_au_start && !sl->use_au_end)
              ^
744.         au_start_flag = au_end_flag = 1;
745.     if (sl->ocr_len > 0)

libavformat/mpegts.c:743:31: Taking true branch
741.     if (sl->use_au_end)
742.         au_end_flag = get_bits1(&gb);
743.     if (!sl->use_au_start && !sl->use_au_end)
                                   ^
744.         au_start_flag = au_end_flag = 1;
745.     if (sl->ocr_len > 0)

libavformat/mpegts.c:744:9: 
742.         au_end_flag = get_bits1(&gb);
743.     if (!sl->use_au_start && !sl->use_au_end)
744.         au_start_flag = au_end_flag = 1;
             ^
745.     if (sl->ocr_len > 0)
746.         ocr_flag = get_bits1(&gb);

libavformat/mpegts.c:745:9: Taking false branch
743.     if (!sl->use_au_start && !sl->use_au_end)
744.         au_start_flag = au_end_flag = 1;
745.     if (sl->ocr_len > 0)
             ^
746.         ocr_flag = get_bits1(&gb);
747.     if (sl->use_idle)

libavformat/mpegts.c:747:9: Taking true branch
745.     if (sl->ocr_len > 0)
746.         ocr_flag = get_bits1(&gb);
747.     if (sl->use_idle)
             ^
748.         idle_flag = get_bits1(&gb);
749.     if (sl->use_padding)

libavformat/mpegts.c:748:9: 
746.         ocr_flag = get_bits1(&gb);
747.     if (sl->use_idle)
748.         idle_flag = get_bits1(&gb);
             ^
749.     if (sl->use_padding)
750.         padding_flag = get_bits1(&gb);

libavcodec/get_bits.h:272:1: start of procedure get_bits1()
  270. }
  271. 
  272. static inline unsigned int get_bits1(GetBitContext *s)
       ^
  273. {
  274.     unsigned int index = s->index;

libavcodec/get_bits.h:274:5: 
  272. static inline unsigned int get_bits1(GetBitContext *s)
  273. {
  274.     unsigned int index = s->index;
           ^
  275.     uint8_t result     = s->buffer[index >> 3];
  276. #ifdef BITSTREAM_READER_LE

libavcodec/get_bits.h:275:5: 
  273. {
  274.     unsigned int index = s->index;
  275.     uint8_t result     = s->buffer[index >> 3];
           ^
  276. #ifdef BITSTREAM_READER_LE
  277.     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;
    if (sl->timestamp_len && sl->timestamp_res)
        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,\n                          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    if (sl->timestamp_len && sl->timestamp_res)\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 int init_get_bits(GetBitContext *s, const uint8_t *buffer,\n                                int bit_size)\n{\n    int buffer_size;\n    int ret = 0;\n    if (bit_size > INT_MAX - 7 || bit_size < 0 || !buffer) {\n        bit_size    = 0;\n        buffer      = NULL;\n        ret         = AVERROR_INVALIDDATA;\n    }\n    buffer_size = (bit_size + 7) >> 3;\n    s->buffer             = buffer;\n    s->size_in_bits       = bit_size;\n#if !UNCHECKED_BITSTREAM_READER\n    s->size_in_bits_plus8 = bit_size + 8;\n#endif\n    s->buffer_end         = buffer + buffer_size;\n    s->index              = 0;\n    return ret;\n}', 'static inline unsigned int get_bits1(GetBitContext *s)\n{\n    unsigned int index = s->index;\n    uint8_t result     = s->buffer[index >> 3];\n#ifdef BITSTREAM_READER_LE\n    result >>= index & 7;\n    result  &= 1;\n#else\n    result <<= index & 7;\n    result >>= 8 - 1;\n#endif\n#if !UNCHECKED_BITSTREAM_READER\n    if (s->index < s->size_in_bits_plus8)\n#endif\n        index++;\n    s->index = index;\n    return result;\n}']