libavcodec/dvdsubdec.c:99: error: Null Dereference
  pointer `&gb->buffer` last assigned on line 90 could be null and is dereferenced by call to `decode_run_8bit()` at line 99, column 19.

libavcodec/dvdsubdec.c:81:1: start of procedure decode_rle()
79. }
80. 
81. static int decode_rle(uint8_t *bitmap, int linesize, int w, int h,
    ^
82.                       const uint8_t *buf, int start, int buf_size, int is_8bit)
83. {

libavcodec/dvdsubdec.c:89:5: 
87.     uint8_t *d;
88. 
89.     bit_len = (buf_size - start) * 8;
        ^
90.     init_get_bits(&gb, buf + start, bit_len);
91. 

libavcodec/dvdsubdec.c:90:5: 
88. 
89.     bit_len = (buf_size - start) * 8;
90.     init_get_bits(&gb, buf + start, bit_len);
        ^
91. 
92.     x = 0;

libavcodec/get_bits.h:391:1: start of procedure init_get_bits()
  389.  * responsible for checking for the buffer end yourself (take advantage of the padding)!
  390.  */
  391. static inline void init_get_bits(GetBitContext *s,
       ^
  392.                    const uint8_t *buffer, int bit_size)
  393. {

libavcodec/get_bits.h:394:5: 
  392.                    const uint8_t *buffer, int bit_size)
  393. {
  394.     int buffer_size = (bit_size+7)>>3;
           ^
  395.     if (buffer_size < 0 || bit_size < 0) {
  396.         buffer_size = bit_size = 0;

libavcodec/get_bits.h:395:9: Taking true branch
  393. {
  394.     int buffer_size = (bit_size+7)>>3;
  395.     if (buffer_size < 0 || bit_size < 0) {
               ^
  396.         buffer_size = bit_size = 0;
  397.         buffer = NULL;

libavcodec/get_bits.h:396:9: 
  394.     int buffer_size = (bit_size+7)>>3;
  395.     if (buffer_size < 0 || bit_size < 0) {
  396.         buffer_size = bit_size = 0;
               ^
  397.         buffer = NULL;
  398.     }

libavcodec/get_bits.h:397:9: 
  395.     if (buffer_size < 0 || bit_size < 0) {
  396.         buffer_size = bit_size = 0;
  397.         buffer = NULL;
               ^
  398.     }
  399. 

libavcodec/get_bits.h:400:5: 
  398.     }
  399. 
  400.     s->buffer       = buffer;
           ^
  401.     s->size_in_bits = bit_size;
  402.     s->buffer_end   = buffer + buffer_size;

libavcodec/get_bits.h:401:5: 
  399. 
  400.     s->buffer       = buffer;
  401.     s->size_in_bits = bit_size;
           ^
  402.     s->buffer_end   = buffer + buffer_size;
  403. #ifdef ALT_BITSTREAM_READER

libavcodec/get_bits.h:402:5: 
  400.     s->buffer       = buffer;
  401.     s->size_in_bits = bit_size;
  402.     s->buffer_end   = buffer + buffer_size;
           ^
  403. #ifdef ALT_BITSTREAM_READER
  404.     s->index        = 0;

libavcodec/get_bits.h:404:5: 
  402.     s->buffer_end   = buffer + buffer_size;
  403. #ifdef ALT_BITSTREAM_READER
  404.     s->index        = 0;
           ^
  405. #elif defined A32_BITSTREAM_READER
  406.     s->buffer_ptr   = (uint32_t*)((intptr_t)buffer & ~3);

libavcodec/get_bits.h:410:1: return from a call to init_get_bits
  408.     skip_bits_long(s, 0);
  409. #endif
  410. }
       ^
  411. 
  412. static inline void align_get_bits(GetBitContext *s)

libavcodec/dvdsubdec.c:92:5: 
90.     init_get_bits(&gb, buf + start, bit_len);
91. 
92.     x = 0;
        ^
93.     y = 0;
94.     d = bitmap;

libavcodec/dvdsubdec.c:93:5: 
91. 
92.     x = 0;
93.     y = 0;
        ^
94.     d = bitmap;
95.     for(;;) {

libavcodec/dvdsubdec.c:94:5: 
92.     x = 0;
93.     y = 0;
94.     d = bitmap;
        ^
95.     for(;;) {
96.         if (get_bits_count(&gb) > bit_len)

libavcodec/dvdsubdec.c:114:5: Loop condition is true. Entering loop body
112.             align_get_bits(&gb);
113.         }
114.     }
         ^
115.     return 0;
116. }

libavcodec/dvdsubdec.c:96:13: 
94.     d = bitmap;
95.     for(;;) {
96.         if (get_bits_count(&gb) > bit_len)
                ^
97.             return -1;
98.         if (is_8bit)

libavcodec/get_bits.h:169:1: start of procedure get_bits_count()
  167. #   define GET_CACHE(name, gb) ((uint32_t)name##_cache)
  168. 
  169. static inline int get_bits_count(const GetBitContext *s){
       ^
  170.     return s->index;
  171. }

libavcodec/get_bits.h:170:5: 
  168. 
  169. static inline int get_bits_count(const GetBitContext *s){
  170.     return s->index;
           ^
  171. }
  172. 

libavcodec/get_bits.h:171:1: return from a call to get_bits_count
  169. static inline int get_bits_count(const GetBitContext *s){
  170.     return s->index;
  171. }
       ^
  172. 
  173. static inline void skip_bits_long(GetBitContext *s, int n){

libavcodec/dvdsubdec.c:96:13: Taking false branch
94.     d = bitmap;
95.     for(;;) {
96.         if (get_bits_count(&gb) > bit_len)
                ^
97.             return -1;
98.         if (is_8bit)

libavcodec/dvdsubdec.c:98:13: Taking true branch
 96.         if (get_bits_count(&gb) > bit_len)
 97.             return -1;
 98.         if (is_8bit)
                 ^
 99.             len = decode_run_8bit(&gb, &color);
100.         else

libavcodec/dvdsubdec.c:99:13: 
 97.             return -1;
 98.         if (is_8bit)
 99.             len = decode_run_8bit(&gb, &color);
                 ^
100.         else
101.             len = decode_run_2bit(&gb, &color);

libavcodec/dvdsubdec.c:59:1: start of procedure decode_run_8bit()
  57. }
  58. 
  59. static int decode_run_8bit(GetBitContext *gb, int *color)
      ^
  60. {
  61.     int len;

libavcodec/dvdsubdec.c:62:5: 
  60. {
  61.     int len;
  62.     int has_run = get_bits1(gb);
          ^
  63.     if (get_bits1(gb))
  64.         *color = get_bits(gb, 8);

libavcodec/get_bits.h:311:1: start of procedure get_bits1()
    309. }
    310. 
    311. static inline unsigned int get_bits1(GetBitContext *s){
         ^
    312. #ifdef ALT_BITSTREAM_READER
    313.     unsigned int index = s->index;

libavcodec/get_bits.h:313:5: 
    311. static inline unsigned int get_bits1(GetBitContext *s){
    312. #ifdef ALT_BITSTREAM_READER
    313.     unsigned int index = s->index;
             ^
    314.     uint8_t result = s->buffer[index>>3];
    315. #ifdef ALT_BITSTREAM_READER_LE

libavcodec/get_bits.h:314:5: 
    312. #ifdef ALT_BITSTREAM_READER
    313.     unsigned int index = s->index;
    314.     uint8_t result = s->buffer[index>>3];
             ^
    315. #ifdef ALT_BITSTREAM_READER_LE
    316.     result >>= index & 7;

libavcodec/get_bits.h:316:5: 
    314.     uint8_t result = s->buffer[index>>3];
    315. #ifdef ALT_BITSTREAM_READER_LE
    316.     result >>= index & 7;
             ^
    317.     result &= 1;
    318. #else

libavcodec/get_bits.h:317:5: 
    315. #ifdef ALT_BITSTREAM_READER_LE
    316.     result >>= index & 7;
    317.     result &= 1;
             ^
    318. #else
    319.     result <<= index & 7;

libavcodec/get_bits.h:322:5: 
    320.     result >>= 8 - 1;
    321. #endif
    322.     index++;
             ^
    323.     s->index = index;
    324. 

libavcodec/get_bits.h:323:5: 
    321. #endif
    322.     index++;
    323.     s->index = index;
             ^
    324. 
    325.     return result;

libavcodec/get_bits.h:325:5: 
    323.     s->index = index;
    324. 
    325.     return result;
             ^
    326. #else
    327.     return get_bits(s, 1);

libavcodec/get_bits.h:329:1: return from a call to get_bits1
    327.     return get_bits(s, 1);
    328. #endif
    329. }
         ^
    330. 
    331. static inline unsigned int show_bits1(GetBitContext *s){

libavcodec/dvdsubdec.c:63:9: 
  61.     int len;
  62.     int has_run = get_bits1(gb);
  63.     if (get_bits1(gb))
              ^
  64.         *color = get_bits(gb, 8);
  65.     else

libavcodec/get_bits.h:311:1: start of procedure get_bits1()
    309. }
    310. 
    311. static inline unsigned int get_bits1(GetBitContext *s){
         ^
    312. #ifdef ALT_BITSTREAM_READER
    313.     unsigned int index = s->index;

libavcodec/get_bits.h:313:5: 
    311. static inline unsigned int get_bits1(GetBitContext *s){
    312. #ifdef ALT_BITSTREAM_READER
    313.     unsigned int index = s->index;
             ^
    314.     uint8_t result = s->buffer[index>>3];
    315. #ifdef ALT_BITSTREAM_READER_LE

libavcodec/get_bits.h:314:5: 
    312. #ifdef ALT_BITSTREAM_READER
    313.     unsigned int index = s->index;
    314.     uint8_t result = s->buffer[index>>3];
             ^
    315. #ifdef ALT_BITSTREAM_READER_LE
    316.     result >>= index & 7;

libavcodec/get_bits.h:316:5: 
    314.     uint8_t result = s->buffer[index>>3];
    315. #ifdef ALT_BITSTREAM_READER_LE
    316.     result >>= index & 7;
             ^
    317.     result &= 1;
    318. #else

libavcodec/get_bits.h:317:5: 
    315. #ifdef ALT_BITSTREAM_READER_LE
    316.     result >>= index & 7;
    317.     result &= 1;
             ^
    318. #else
    319.     result <<= index & 7;

libavcodec/get_bits.h:322:5: 
    320.     result >>= 8 - 1;
    321. #endif
    322.     index++;
             ^
    323.     s->index = index;
    324. 

libavcodec/get_bits.h:323:5: 
    321. #endif
    322.     index++;
    323.     s->index = index;
             ^
    324. 
    325.     return result;

libavcodec/get_bits.h:325:5: 
    323.     s->index = index;
    324. 
    325.     return result;
             ^
    326. #else
    327.     return get_bits(s, 1);

libavcodec/get_bits.h:329:1: return from a call to get_bits1
    327.     return get_bits(s, 1);
    328. #endif
    329. }
         ^
    330. 
    331. static inline unsigned int show_bits1(GetBitContext *s){

libavcodec/dvdsubdec.c:63:9: Taking false branch
  61.     int len;
  62.     int has_run = get_bits1(gb);
  63.     if (get_bits1(gb))
              ^
  64.         *color = get_bits(gb, 8);
  65.     else

libavcodec/dvdsubdec.c:66:9: 
  64.         *color = get_bits(gb, 8);
  65.     else
  66.         *color = get_bits(gb, 2);
              ^
  67.     if (has_run) {
  68.         if (get_bits1(gb)) {

libavcodec/get_bits.h:282:1: start of procedure get_bits()
    280.  * Read 1-25 bits.
    281.  */
    282. static inline unsigned int get_bits(GetBitContext *s, int n){
         ^
    283.     register int tmp;
    284.     OPEN_READER(re, s);

libavcodec/get_bits.h:284:5: 
    282. static inline unsigned int get_bits(GetBitContext *s, int n){
    283.     register int tmp;
    284.     OPEN_READER(re, s);
             ^
    285.     UPDATE_CACHE(re, s);
    286.     tmp = SHOW_UBITS(re, s, n);

libavcodec/get_bits.h:285:5: 
    283.     register int tmp;
    284.     OPEN_READER(re, s);
    285.     UPDATE_CACHE(re, s);
             ^
    286.     tmp = SHOW_UBITS(re, s, n);
    287.     LAST_SKIP_BITS(re, s, n);

libavutil/bswap.h:66:1: start of procedure av_bswap32()
      64. 
      65. #ifndef av_bswap32
      66. static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
          ^
      67. {
      68.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);

libavutil/bswap.h:68:5: 
      66. static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
      67. {
      68.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
              ^
      69.     x= (x>>16) | (x<<16);
      70.     return x;

libavutil/bswap.h:69:5: 
      67. {
      68.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
      69.     x= (x>>16) | (x<<16);
              ^
      70.     return x;
      71. }

libavutil/bswap.h:70:5: 
      68.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
      69.     x= (x>>16) | (x<<16);
      70.     return x;
              ^
      71. }
      72. #endif

libavutil/bswap.h:71:1: return from a call to av_bswap32
      69.     x= (x>>16) | (x<<16);
      70.     return x;
      71. }
          ^
      72. #endif
      73. 

libavcodec/get_bits.h:286:5: 
    284.     OPEN_READER(re, s);
    285.     UPDATE_CACHE(re, s);
    286.     tmp = SHOW_UBITS(re, s, n);
             ^
    287.     LAST_SKIP_BITS(re, s, n);
    288.     CLOSE_READER(re, s);

libavcodec/get_bits.h:287:5: 
    285.     UPDATE_CACHE(re, s);
    286.     tmp = SHOW_UBITS(re, s, n);
    287.     LAST_SKIP_BITS(re, s, n);
             ^
    288.     CLOSE_READER(re, s);
    289.     return tmp;

libavcodec/get_bits.h:288:5: 
    286.     tmp = SHOW_UBITS(re, s, n);
    287.     LAST_SKIP_BITS(re, s, n);
    288.     CLOSE_READER(re, s);
             ^
    289.     return tmp;
    290. }

libavcodec/get_bits.h:289:5: 
    287.     LAST_SKIP_BITS(re, s, n);
    288.     CLOSE_READER(re, s);
    289.     return tmp;
             ^
    290. }
    291. 

libavcodec/get_bits.h:290:1: return from a call to get_bits
    288.     CLOSE_READER(re, s);
    289.     return tmp;
    290. }
         ^
    291. 
    292. /**

libavcodec/dvdsubdec.c:67:9: Taking true branch
  65.     else
  66.         *color = get_bits(gb, 2);
  67.     if (has_run) {
              ^
  68.         if (get_bits1(gb)) {
  69.             len = get_bits(gb, 7);

libavcodec/dvdsubdec.c:68:13: 
  66.         *color = get_bits(gb, 2);
  67.     if (has_run) {
  68.         if (get_bits1(gb)) {
                  ^
  69.             len = get_bits(gb, 7);
  70.             if (len == 0)

libavcodec/get_bits.h:311:1: start of procedure get_bits1()
    309. }
    310. 
    311. static inline unsigned int get_bits1(GetBitContext *s){
         ^
    312. #ifdef ALT_BITSTREAM_READER
    313.     unsigned int index = s->index;

libavcodec/get_bits.h:313:5: 
    311. static inline unsigned int get_bits1(GetBitContext *s){
    312. #ifdef ALT_BITSTREAM_READER
    313.     unsigned int index = s->index;
             ^
    314.     uint8_t result = s->buffer[index>>3];
    315. #ifdef ALT_BITSTREAM_READER_LE

libavcodec/get_bits.h:314:5: 
    312. #ifdef ALT_BITSTREAM_READER
    313.     unsigned int index = s->index;
    314.     uint8_t result = s->buffer[index>>3];
             ^
    315. #ifdef ALT_BITSTREAM_READER_LE
    316.     result >>= index & 7;

static int decode_rle(uint8_t *bitmap, int linesize, int w, int h,
                      const uint8_t *buf, int start, int buf_size, int is_8bit)
{
    GetBitContext gb;
    int bit_len;
    int x, y, len, color;
    uint8_t *d;
    bit_len = (buf_size - start) * 8;
    init_get_bits(&gb, buf + start, bit_len);
    x = 0;
    y = 0;
    d = bitmap;
    for(;;) {
        if (get_bits_count(&gb) > bit_len)
            return -1;
        if (is_8bit)
            len = decode_run_8bit(&gb, &color);
        else
            len = decode_run_2bit(&gb, &color);
        len = FFMIN(len, w - x);
        memset(d + x, color, len);
        x += len;
        if (x >= w) {
            y++;
            if (y >= h)
                break;
            d += linesize;
            x = 0;
            align_get_bits(&gb);
        }
    }
    return 0;
}
['static int decode_rle(uint8_t *bitmap, int linesize, int w, int h,\n                      const uint8_t *buf, int start, int buf_size, int is_8bit)\n{\n    GetBitContext gb;\n    int bit_len;\n    int x, y, len, color;\n    uint8_t *d;\n    bit_len = (buf_size - start) * 8;\n    init_get_bits(&gb, buf + start, bit_len);\n    x = 0;\n    y = 0;\n    d = bitmap;\n    for(;;) {\n        if (get_bits_count(&gb) > bit_len)\n            return -1;\n        if (is_8bit)\n            len = decode_run_8bit(&gb, &color);\n        else\n            len = decode_run_2bit(&gb, &color);\n        len = FFMIN(len, w - x);\n        memset(d + x, color, len);\n        x += len;\n        if (x >= w) {\n            y++;\n            if (y >= h)\n                break;\n            d += linesize;\n            x = 0;\n            align_get_bits(&gb);\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    s->buffer_end   = buffer + buffer_size;\n#ifdef ALT_BITSTREAM_READER\n    s->index        = 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 int get_bits_count(const GetBitContext *s){\n    return s->index;\n}', 'static int decode_run_8bit(GetBitContext *gb, int *color)\n{\n    int len;\n    int has_run = get_bits1(gb);\n    if (get_bits1(gb))\n        *color = get_bits(gb, 8);\n    else\n        *color = get_bits(gb, 2);\n    if (has_run) {\n        if (get_bits1(gb)) {\n            len = get_bits(gb, 7);\n            if (len == 0)\n                len = INT_MAX;\n            else\n                len += 9;\n        } else\n            len = get_bits(gb, 3) + 2;\n    } else\n        len = 1;\n    return len;\n}', 'static inline unsigned int get_bits1(GetBitContext *s){\n#ifdef ALT_BITSTREAM_READER\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#else\n    return get_bits(s, 1);\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}', 'static av_always_inline av_const uint32_t av_bswap32(uint32_t x)\n{\n    x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);\n    x= (x>>16) | (x<<16);\n    return x;\n}']