libavcodec/xan.c:115: error: Null Dereference
  pointer `&gb->buffer` last assigned on line 112 could be null and is dereferenced by call to `get_bits1()` at line 115, column 37.

libavcodec/xan.c:98:1: start of procedure xan_huffman_decode()
 96. }
 97. 
 98. static int xan_huffman_decode(unsigned char *dest, int dest_len,
     ^
 99.                               const unsigned char *src, int src_len)
100. {

libavcodec/xan.c:101:5: 
 99.                               const unsigned char *src, int src_len)
100. {
101.     unsigned char byte = *src++;
         ^
102.     unsigned char ival = byte + 0x16;
103.     const unsigned char * ptr = src + byte*2;

libavcodec/xan.c:102:5: 
100. {
101.     unsigned char byte = *src++;
102.     unsigned char ival = byte + 0x16;
         ^
103.     const unsigned char * ptr = src + byte*2;
104.     int ptr_len = src_len - 1 - byte*2;

libavcodec/xan.c:103:5: 
101.     unsigned char byte = *src++;
102.     unsigned char ival = byte + 0x16;
103.     const unsigned char * ptr = src + byte*2;
         ^
104.     int ptr_len = src_len - 1 - byte*2;
105.     unsigned char val = ival;

libavcodec/xan.c:104:5: 
102.     unsigned char ival = byte + 0x16;
103.     const unsigned char * ptr = src + byte*2;
104.     int ptr_len = src_len - 1 - byte*2;
         ^
105.     unsigned char val = ival;
106.     unsigned char *dest_end = dest + dest_len;

libavcodec/xan.c:105:5: 
103.     const unsigned char * ptr = src + byte*2;
104.     int ptr_len = src_len - 1 - byte*2;
105.     unsigned char val = ival;
         ^
106.     unsigned char *dest_end = dest + dest_len;
107.     GetBitContext gb;

libavcodec/xan.c:106:5: 
104.     int ptr_len = src_len - 1 - byte*2;
105.     unsigned char val = ival;
106.     unsigned char *dest_end = dest + dest_len;
         ^
107.     GetBitContext gb;
108. 

libavcodec/xan.c:109:9: Taking false branch
107.     GetBitContext gb;
108. 
109.     if (ptr_len < 0)
             ^
110.         return AVERROR_INVALIDDATA;
111. 

libavcodec/xan.c:112:5: 
110.         return AVERROR_INVALIDDATA;
111. 
112.     init_get_bits(&gb, ptr, ptr_len * 8);
         ^
113. 
114.     while (val != 0x16) {

libavcodec/get_bits.h:338:1: start of procedure init_get_bits()
  336.  * responsible for checking for the buffer end yourself (take advantage of the padding)!
  337.  */
  338. static inline void init_get_bits(GetBitContext *s,
       ^
  339.                    const uint8_t *buffer, int bit_size)
  340. {

libavcodec/get_bits.h:341:5: 
  339.                    const uint8_t *buffer, int bit_size)
  340. {
  341.     int buffer_size = (bit_size+7)>>3;
           ^
  342.     if (buffer_size < 0 || bit_size < 0) {
  343.         buffer_size = bit_size = 0;

libavcodec/get_bits.h:342:9: Taking true branch
  340. {
  341.     int buffer_size = (bit_size+7)>>3;
  342.     if (buffer_size < 0 || bit_size < 0) {
               ^
  343.         buffer_size = bit_size = 0;
  344.         buffer = NULL;

libavcodec/get_bits.h:343:9: 
  341.     int buffer_size = (bit_size+7)>>3;
  342.     if (buffer_size < 0 || bit_size < 0) {
  343.         buffer_size = bit_size = 0;
               ^
  344.         buffer = NULL;
  345.     }

libavcodec/get_bits.h:344:9: 
  342.     if (buffer_size < 0 || bit_size < 0) {
  343.         buffer_size = bit_size = 0;
  344.         buffer = NULL;
               ^
  345.     }
  346. 

libavcodec/get_bits.h:347:5: 
  345.     }
  346. 
  347.     s->buffer       = buffer;
           ^
  348.     s->size_in_bits = bit_size;
  349. #if !UNCHECKED_BITSTREAM_READER

libavcodec/get_bits.h:348:5: 
  346. 
  347.     s->buffer       = buffer;
  348.     s->size_in_bits = bit_size;
           ^
  349. #if !UNCHECKED_BITSTREAM_READER
  350.     s->size_in_bits_plus8 = bit_size + 8;

libavcodec/get_bits.h:350:5: 
  348.     s->size_in_bits = bit_size;
  349. #if !UNCHECKED_BITSTREAM_READER
  350.     s->size_in_bits_plus8 = bit_size + 8;
           ^
  351. #endif
  352.     s->buffer_end   = buffer + buffer_size;

libavcodec/get_bits.h:352:5: 
  350.     s->size_in_bits_plus8 = bit_size + 8;
  351. #endif
  352.     s->buffer_end   = buffer + buffer_size;
           ^
  353.     s->index        = 0;
  354. }

libavcodec/get_bits.h:353:5: 
  351. #endif
  352.     s->buffer_end   = buffer + buffer_size;
  353.     s->index        = 0;
           ^
  354. }
  355. 

libavcodec/get_bits.h:354:1: return from a call to init_get_bits
  352.     s->buffer_end   = buffer + buffer_size;
  353.     s->index        = 0;
  354. }
       ^
  355. 
  356. static inline void align_get_bits(GetBitContext *s)

libavcodec/xan.c:114:12: Loop condition is true. Entering loop body
112.     init_get_bits(&gb, ptr, ptr_len * 8);
113. 
114.     while (val != 0x16) {
                ^
115.         unsigned idx = val - 0x17 + get_bits1(&gb) * byte;
116.         if (idx >= 2 * byte)

libavcodec/xan.c:115:9: 
113. 
114.     while (val != 0x16) {
115.         unsigned idx = val - 0x17 + get_bits1(&gb) * byte;
             ^
116.         if (idx >= 2 * byte)
117.             return -1;

libavcodec/get_bits.h:259:1: start of procedure get_bits1()
  257. }
  258. 
  259. static inline unsigned int get_bits1(GetBitContext *s){
       ^
  260.     unsigned int index = s->index;
  261.     uint8_t result = s->buffer[index>>3];

libavcodec/get_bits.h:260:5: 
  258. 
  259. static inline unsigned int get_bits1(GetBitContext *s){
  260.     unsigned int index = s->index;
           ^
  261.     uint8_t result = s->buffer[index>>3];
  262. #ifdef ALT_BITSTREAM_READER_LE

libavcodec/get_bits.h:261:5: 
  259. static inline unsigned int get_bits1(GetBitContext *s){
  260.     unsigned int index = s->index;
  261.     uint8_t result = s->buffer[index>>3];
           ^
  262. #ifdef ALT_BITSTREAM_READER_LE
  263.     result >>= index & 7;

static int xan_huffman_decode(unsigned char *dest, int dest_len,
                              const unsigned char *src, int src_len)
{
    unsigned char byte = *src++;
    unsigned char ival = byte + 0x16;
    const unsigned char * ptr = src + byte*2;
    int ptr_len = src_len - 1 - byte*2;
    unsigned char val = ival;
    unsigned char *dest_end = dest + dest_len;
    GetBitContext gb;
    if (ptr_len < 0)
        return AVERROR_INVALIDDATA;
    init_get_bits(&gb, ptr, ptr_len * 8);
    while (val != 0x16) {
        unsigned idx = val - 0x17 + get_bits1(&gb) * byte;
        if (idx >= 2 * byte)
            return -1;
        val = src[idx];
        if (val < 0x16) {
            if (dest >= dest_end)
                return 0;
            *dest++ = val;
            val = ival;
        }
    }
    return 0;
}
['static int xan_huffman_decode(unsigned char *dest, int dest_len,\n                              const unsigned char *src, int src_len)\n{\n    unsigned char byte = *src++;\n    unsigned char ival = byte + 0x16;\n    const unsigned char * ptr = src + byte*2;\n    int ptr_len = src_len - 1 - byte*2;\n    unsigned char val = ival;\n    unsigned char *dest_end = dest + dest_len;\n    GetBitContext gb;\n    if (ptr_len < 0)\n        return AVERROR_INVALIDDATA;\n    init_get_bits(&gb, ptr, ptr_len * 8);\n    while (val != 0x16) {\n        unsigned idx = val - 0x17 + get_bits1(&gb) * byte;\n        if (idx >= 2 * byte)\n            return -1;\n        val = src[idx];\n        if (val < 0x16) {\n            if (dest >= dest_end)\n                return 0;\n            *dest++ = val;\n            val = ival;\n        }\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#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}', '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#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}']