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:473:1: start of procedure init_get_bits()
  471.  * responsible for checking for the buffer end yourself (take advantage of the padding)!
  472.  */
  473. static inline void init_get_bits(GetBitContext *s,
       ^
  474.                    const uint8_t *buffer, int bit_size)
  475. {

libavcodec/get_bits.h:476:5: 
  474.                    const uint8_t *buffer, int bit_size)
  475. {
  476.     int buffer_size= (bit_size+7)>>3;
           ^
  477.     if(buffer_size < 0 || bit_size < 0) {
  478.         buffer_size = bit_size = 0;

libavcodec/get_bits.h:477:8: Taking true branch
  475. {
  476.     int buffer_size= (bit_size+7)>>3;
  477.     if(buffer_size < 0 || bit_size < 0) {
              ^
  478.         buffer_size = bit_size = 0;
  479.         buffer = NULL;

libavcodec/get_bits.h:478:9: 
  476.     int buffer_size= (bit_size+7)>>3;
  477.     if(buffer_size < 0 || bit_size < 0) {
  478.         buffer_size = bit_size = 0;
               ^
  479.         buffer = NULL;
  480.     }

libavcodec/get_bits.h:479:9: 
  477.     if(buffer_size < 0 || bit_size < 0) {
  478.         buffer_size = bit_size = 0;
  479.         buffer = NULL;
               ^
  480.     }
  481. 

libavcodec/get_bits.h:482:5: 
  480.     }
  481. 
  482.     s->buffer= buffer;
           ^
  483.     s->size_in_bits= bit_size;
  484.     s->buffer_end= buffer + buffer_size;

libavcodec/get_bits.h:483:5: 
  481. 
  482.     s->buffer= buffer;
  483.     s->size_in_bits= bit_size;
           ^
  484.     s->buffer_end= buffer + buffer_size;
  485. #ifdef ALT_BITSTREAM_READER

libavcodec/get_bits.h:484:5: 
  482.     s->buffer= buffer;
  483.     s->size_in_bits= bit_size;
  484.     s->buffer_end= buffer + buffer_size;
           ^
  485. #ifdef ALT_BITSTREAM_READER
  486.     s->index=0;

libavcodec/get_bits.h:486:5: 
  484.     s->buffer_end= buffer + buffer_size;
  485. #ifdef ALT_BITSTREAM_READER
  486.     s->index=0;
           ^
  487. #elif defined LIBMPEG2_BITSTREAM_READER
  488.     s->buffer_ptr = (uint8_t*)((intptr_t)buffer&(~1));

libavcodec/get_bits.h:496:1: return from a call to init_get_bits
  494.     skip_bits_long(s, 0);
  495. #endif
  496. }
       ^
  497. 
  498. 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:184:1: start of procedure get_bits_count()
  182.         ((uint32_t)name##_cache)
  183. 
  184. static inline int get_bits_count(const GetBitContext *s){
       ^
  185.     return s->index;
  186. }

libavcodec/get_bits.h:185:5: 
  183. 
  184. static inline int get_bits_count(const GetBitContext *s){
  185.     return s->index;
           ^
  186. }
  187. 

libavcodec/get_bits.h:186:1: return from a call to get_bits_count
  184. static inline int get_bits_count(const GetBitContext *s){
  185.     return s->index;
  186. }
       ^
  187. 
  188. 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:393:1: start of procedure get_bits1()
    391. }
    392. 
    393. static inline unsigned int get_bits1(GetBitContext *s){
         ^
    394. #ifdef ALT_BITSTREAM_READER
    395.     unsigned int index= s->index;

libavcodec/get_bits.h:395:5: 
    393. static inline unsigned int get_bits1(GetBitContext *s){
    394. #ifdef ALT_BITSTREAM_READER
    395.     unsigned int index= s->index;
             ^
    396.     uint8_t result= s->buffer[ index>>3 ];
    397. #ifdef ALT_BITSTREAM_READER_LE

libavcodec/get_bits.h:396:5: 
    394. #ifdef ALT_BITSTREAM_READER
    395.     unsigned int index= s->index;
    396.     uint8_t result= s->buffer[ index>>3 ];
             ^
    397. #ifdef ALT_BITSTREAM_READER_LE
    398.     result>>= (index&0x07);

libavcodec/get_bits.h:398:5: 
    396.     uint8_t result= s->buffer[ index>>3 ];
    397. #ifdef ALT_BITSTREAM_READER_LE
    398.     result>>= (index&0x07);
             ^
    399.     result&= 1;
    400. #else

libavcodec/get_bits.h:399:5: 
    397. #ifdef ALT_BITSTREAM_READER_LE
    398.     result>>= (index&0x07);
    399.     result&= 1;
             ^
    400. #else
    401.     result<<= (index&0x07);

libavcodec/get_bits.h:404:5: 
    402.     result>>= 8 - 1;
    403. #endif
    404.     index++;
             ^
    405.     s->index= index;
    406. 

libavcodec/get_bits.h:405:5: 
    403. #endif
    404.     index++;
    405.     s->index= index;
             ^
    406. 
    407.     return result;

libavcodec/get_bits.h:407:5: 
    405.     s->index= index;
    406. 
    407.     return result;
             ^
    408. #else
    409.     return get_bits(s, 1);

libavcodec/get_bits.h:411:1: return from a call to get_bits1
    409.     return get_bits(s, 1);
    410. #endif
    411. }
         ^
    412. 
    413. 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:393:1: start of procedure get_bits1()
    391. }
    392. 
    393. static inline unsigned int get_bits1(GetBitContext *s){
         ^
    394. #ifdef ALT_BITSTREAM_READER
    395.     unsigned int index= s->index;

libavcodec/get_bits.h:395:5: 
    393. static inline unsigned int get_bits1(GetBitContext *s){
    394. #ifdef ALT_BITSTREAM_READER
    395.     unsigned int index= s->index;
             ^
    396.     uint8_t result= s->buffer[ index>>3 ];
    397. #ifdef ALT_BITSTREAM_READER_LE

libavcodec/get_bits.h:396:5: 
    394. #ifdef ALT_BITSTREAM_READER
    395.     unsigned int index= s->index;
    396.     uint8_t result= s->buffer[ index>>3 ];
             ^
    397. #ifdef ALT_BITSTREAM_READER_LE
    398.     result>>= (index&0x07);

libavcodec/get_bits.h:398:5: 
    396.     uint8_t result= s->buffer[ index>>3 ];
    397. #ifdef ALT_BITSTREAM_READER_LE
    398.     result>>= (index&0x07);
             ^
    399.     result&= 1;
    400. #else

libavcodec/get_bits.h:399:5: 
    397. #ifdef ALT_BITSTREAM_READER_LE
    398.     result>>= (index&0x07);
    399.     result&= 1;
             ^
    400. #else
    401.     result<<= (index&0x07);

libavcodec/get_bits.h:404:5: 
    402.     result>>= 8 - 1;
    403. #endif
    404.     index++;
             ^
    405.     s->index= index;
    406. 

libavcodec/get_bits.h:405:5: 
    403. #endif
    404.     index++;
    405.     s->index= index;
             ^
    406. 
    407.     return result;

libavcodec/get_bits.h:407:5: 
    405.     s->index= index;
    406. 
    407.     return result;
             ^
    408. #else
    409.     return get_bits(s, 1);

libavcodec/get_bits.h:411:1: return from a call to get_bits1
    409.     return get_bits(s, 1);
    410. #endif
    411. }
         ^
    412. 
    413. 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:362:1: start of procedure get_bits()
    360.  * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't
    361.  */
    362. static inline unsigned int get_bits(GetBitContext *s, int n){
         ^
    363.     register int tmp;
    364.     OPEN_READER(re, s)

libavcodec/get_bits.h:364:5: 
    362. static inline unsigned int get_bits(GetBitContext *s, int n){
    363.     register int tmp;
    364.     OPEN_READER(re, s)
             ^
    365.     UPDATE_CACHE(re, s)
    366.     tmp= SHOW_UBITS(re, s, n);

libavcodec/get_bits.h:365:5: 
    363.     register int tmp;
    364.     OPEN_READER(re, s)
    365.     UPDATE_CACHE(re, s)
             ^
    366.     tmp= SHOW_UBITS(re, s, n);
    367.     LAST_SKIP_BITS(re, s, n)

libavutil/bswap.h:54:1: start of procedure bswap_32()
      52. 
      53. #ifndef bswap_32
      54. static av_always_inline av_const uint32_t bswap_32(uint32_t x)
          ^
      55. {
      56.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);

libavutil/bswap.h:56:5: 
      54. static av_always_inline av_const uint32_t bswap_32(uint32_t x)
      55. {
      56.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
              ^
      57.     x= (x>>16) | (x<<16);
      58.     return x;

libavutil/bswap.h:57:5: 
      55. {
      56.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
      57.     x= (x>>16) | (x<<16);
              ^
      58.     return x;
      59. }

libavutil/bswap.h:58:5: 
      56.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
      57.     x= (x>>16) | (x<<16);
      58.     return x;
              ^
      59. }
      60. #endif

libavutil/bswap.h:59:1: return from a call to bswap_32
      57.     x= (x>>16) | (x<<16);
      58.     return x;
      59. }
          ^
      60. #endif
      61. 

libavcodec/get_bits.h:366:5: 
    364.     OPEN_READER(re, s)
    365.     UPDATE_CACHE(re, s)
    366.     tmp= SHOW_UBITS(re, s, n);
             ^
    367.     LAST_SKIP_BITS(re, s, n)
    368.     CLOSE_READER(re, s)

libavcodec/get_bits.h:367:5: 
    365.     UPDATE_CACHE(re, s)
    366.     tmp= SHOW_UBITS(re, s, n);
    367.     LAST_SKIP_BITS(re, s, n)
             ^
    368.     CLOSE_READER(re, s)
    369.     return tmp;

libavcodec/get_bits.h:368:5: 
    366.     tmp= SHOW_UBITS(re, s, n);
    367.     LAST_SKIP_BITS(re, s, n)
    368.     CLOSE_READER(re, s)
             ^
    369.     return tmp;
    370. }

libavcodec/get_bits.h:369:5: 
    367.     LAST_SKIP_BITS(re, s, n)
    368.     CLOSE_READER(re, s)
    369.     return tmp;
             ^
    370. }
    371. 

libavcodec/get_bits.h:370:1: return from a call to get_bits
    368.     CLOSE_READER(re, s)
    369.     return tmp;
    370. }
         ^
    371. 
    372. /**

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:393:1: start of procedure get_bits1()
    391. }
    392. 
    393. static inline unsigned int get_bits1(GetBitContext *s){
         ^
    394. #ifdef ALT_BITSTREAM_READER
    395.     unsigned int index= s->index;

libavcodec/get_bits.h:395:5: 
    393. static inline unsigned int get_bits1(GetBitContext *s){
    394. #ifdef ALT_BITSTREAM_READER
    395.     unsigned int index= s->index;
             ^
    396.     uint8_t result= s->buffer[ index>>3 ];
    397. #ifdef ALT_BITSTREAM_READER_LE

libavcodec/get_bits.h:396:5: 
    394. #ifdef ALT_BITSTREAM_READER
    395.     unsigned int index= s->index;
    396.     uint8_t result= s->buffer[ index>>3 ];
             ^
    397. #ifdef ALT_BITSTREAM_READER_LE
    398.     result>>= (index&0x07);

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 LIBMPEG2_BITSTREAM_READER\n    s->buffer_ptr = (uint8_t*)((intptr_t)buffer&(~1));\n    s->bit_count = 16 + 8*((intptr_t)buffer&1);\n    skip_bits_long(s, 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&0x07);\n    result&= 1;\n#else\n    result<<= (index&0x07);\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 bswap_32(uint32_t x)\n{\n    x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);\n    x= (x>>16) | (x<<16);\n    return x;\n}']