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

libavcodec/xan.c:116:1: start of procedure xan_huffman_decode()
114. }
115. 
116. static int xan_huffman_decode(unsigned char *dest, int dest_len,
     ^
117.                               const unsigned char *src, int src_len)
118. {

libavcodec/xan.c:119:5: 
117.                               const unsigned char *src, int src_len)
118. {
119.     unsigned char byte = *src++;
         ^
120.     unsigned char ival = byte + 0x16;
121.     const unsigned char * ptr = src + byte*2;

libavcodec/xan.c:120:5: 
118. {
119.     unsigned char byte = *src++;
120.     unsigned char ival = byte + 0x16;
         ^
121.     const unsigned char * ptr = src + byte*2;
122.     int ptr_len = src_len - 1 - byte*2;

libavcodec/xan.c:121:5: 
119.     unsigned char byte = *src++;
120.     unsigned char ival = byte + 0x16;
121.     const unsigned char * ptr = src + byte*2;
         ^
122.     int ptr_len = src_len - 1 - byte*2;
123.     unsigned char val = ival;

libavcodec/xan.c:122:5: 
120.     unsigned char ival = byte + 0x16;
121.     const unsigned char * ptr = src + byte*2;
122.     int ptr_len = src_len - 1 - byte*2;
         ^
123.     unsigned char val = ival;
124.     unsigned char *dest_end = dest + dest_len;

libavcodec/xan.c:123:5: 
121.     const unsigned char * ptr = src + byte*2;
122.     int ptr_len = src_len - 1 - byte*2;
123.     unsigned char val = ival;
         ^
124.     unsigned char *dest_end = dest + dest_len;
125.     unsigned char *dest_start = dest;

libavcodec/xan.c:124:5: 
122.     int ptr_len = src_len - 1 - byte*2;
123.     unsigned char val = ival;
124.     unsigned char *dest_end = dest + dest_len;
         ^
125.     unsigned char *dest_start = dest;
126.     GetBitContext gb;

libavcodec/xan.c:125:5: 
123.     unsigned char val = ival;
124.     unsigned char *dest_end = dest + dest_len;
125.     unsigned char *dest_start = dest;
         ^
126.     GetBitContext gb;
127. 

libavcodec/xan.c:128:9: Taking false branch
126.     GetBitContext gb;
127. 
128.     if (ptr_len < 0)
             ^
129.         return AVERROR_INVALIDDATA;
130. 

libavcodec/xan.c:131:5: 
129.         return AVERROR_INVALIDDATA;
130. 
131.     init_get_bits(&gb, ptr, ptr_len * 8);
         ^
132. 
133.     while (val != 0x16) {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

libavcodec/xan.c:134:9: 
132. 
133.     while (val != 0x16) {
134.         unsigned idx = val - 0x17 + get_bits1(&gb) * byte;
             ^
135.         if (idx >= 2 * byte)
136.             return AVERROR_INVALIDDATA;

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

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

libavcodec/get_bits.h:274:5: 
  272. {
  273.     unsigned int index = s->index;
  274.     uint8_t result     = s->buffer[index >> 3];
           ^
  275. #ifdef BITSTREAM_READER_LE
  276.     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;
    unsigned char *dest_start = dest;
    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 AVERROR_INVALIDDATA;
        val = src[idx];
        if (val < 0x16) {
            if (dest >= dest_end)
                return dest_len;
            *dest++ = val;
            val = ival;
        }
    }
    return dest - dest_start;
}
['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    unsigned char *dest_start = dest;\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 AVERROR_INVALIDDATA;\n        val = src[idx];\n        if (val < 0x16) {\n            if (dest >= dest_end)\n                return dest_len;\n            *dest++ = val;\n            val = ival;\n        }\n    }\n    return dest - dest_start;\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        buffer_size = 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}']