libavcodec/mjpegbdec.c:54: error: Null Dereference
  pointer `&hgb->buffer` last assigned on line 52 could be null and is dereferenced by call to `skip_bits()` at line 54, column 5.

libavcodec/mjpegbdec.c:32:1: start of procedure mjpegb_decode_frame()
30. 
31. 
32. static int mjpegb_decode_frame(AVCodecContext *avctx,
    ^
33.                               void *data, int *data_size,
34.                               const uint8_t *buf, int buf_size)

libavcodec/mjpegbdec.c:36:5: 
34.                               const uint8_t *buf, int buf_size)
35. {
36.     MJpegDecodeContext *s = avctx->priv_data;
        ^
37.     const uint8_t *buf_end, *buf_ptr;
38.     AVFrame *picture = data;

libavcodec/mjpegbdec.c:38:5: 
36.     MJpegDecodeContext *s = avctx->priv_data;
37.     const uint8_t *buf_end, *buf_ptr;
38.     AVFrame *picture = data;
        ^
39.     GetBitContext hgb; /* for the header */
40.     uint32_t dqt_offs, dht_offs, sof_offs, sos_offs, second_field_offs;

libavcodec/mjpegbdec.c:43:5: 
41.     uint32_t field_size, sod_offs;
42. 
43.     buf_ptr = buf;
        ^
44.     buf_end = buf + buf_size;
45. 

libavcodec/mjpegbdec.c:44:5: 
42. 
43.     buf_ptr = buf;
44.     buf_end = buf + buf_size;
        ^
45. 
46. read_header:

libavcodec/mjpegbdec.c:116:13: 
114.             buf_ptr = buf + second_field_offs;
115.             second_field_offs = 0;
116.             goto read_header;
                 ^
117.             }
118.     }

libavcodec/mjpegbdec.c:48:5: 
46. read_header:
47.     /* reset on every SOI */
48.     s->restart_interval = 0;
        ^
49.     s->restart_count = 0;
50.     s->mjpb_skiptosod = 0;

libavcodec/mjpegbdec.c:49:5: 
47.     /* reset on every SOI */
48.     s->restart_interval = 0;
49.     s->restart_count = 0;
        ^
50.     s->mjpb_skiptosod = 0;
51. 

libavcodec/mjpegbdec.c:50:5: 
48.     s->restart_interval = 0;
49.     s->restart_count = 0;
50.     s->mjpb_skiptosod = 0;
        ^
51. 
52.     init_get_bits(&hgb, buf_ptr, /*buf_size*/(buf_end - buf_ptr)*8);

libavcodec/mjpegbdec.c:52:5: 
50.     s->mjpb_skiptosod = 0;
51. 
52.     init_get_bits(&hgb, buf_ptr, /*buf_size*/(buf_end - buf_ptr)*8);
        ^
53. 
54.     skip_bits(&hgb, 32); /* reserved zeros */

libavcodec/bitstream.h:758:1: start of procedure init_get_bits()
  756.  * @param bit_size the size of the buffer in bits
  757.  */
  758. static inline void init_get_bits(GetBitContext *s,
       ^
  759.                    const uint8_t *buffer, int bit_size)
  760. {

libavcodec/bitstream.h:761:5: 
  759.                    const uint8_t *buffer, int bit_size)
  760. {
  761.     int buffer_size= (bit_size+7)>>3;
           ^
  762.     if(buffer_size < 0 || bit_size < 0) {
  763.         buffer_size = bit_size = 0;

libavcodec/bitstream.h:762:8: Taking true branch
  760. {
  761.     int buffer_size= (bit_size+7)>>3;
  762.     if(buffer_size < 0 || bit_size < 0) {
              ^
  763.         buffer_size = bit_size = 0;
  764.         buffer = NULL;

libavcodec/bitstream.h:763:9: 
  761.     int buffer_size= (bit_size+7)>>3;
  762.     if(buffer_size < 0 || bit_size < 0) {
  763.         buffer_size = bit_size = 0;
               ^
  764.         buffer = NULL;
  765.     }

libavcodec/bitstream.h:764:9: 
  762.     if(buffer_size < 0 || bit_size < 0) {
  763.         buffer_size = bit_size = 0;
  764.         buffer = NULL;
               ^
  765.     }
  766. 

libavcodec/bitstream.h:767:5: 
  765.     }
  766. 
  767.     s->buffer= buffer;
           ^
  768.     s->size_in_bits= bit_size;
  769.     s->buffer_end= buffer + buffer_size;

libavcodec/bitstream.h:768:5: 
  766. 
  767.     s->buffer= buffer;
  768.     s->size_in_bits= bit_size;
           ^
  769.     s->buffer_end= buffer + buffer_size;
  770. #ifdef ALT_BITSTREAM_READER

libavcodec/bitstream.h:769:5: 
  767.     s->buffer= buffer;
  768.     s->size_in_bits= bit_size;
  769.     s->buffer_end= buffer + buffer_size;
           ^
  770. #ifdef ALT_BITSTREAM_READER
  771.     s->index=0;

libavcodec/bitstream.h:771:5: 
  769.     s->buffer_end= buffer + buffer_size;
  770. #ifdef ALT_BITSTREAM_READER
  771.     s->index=0;
           ^
  772. #elif defined LIBMPEG2_BITSTREAM_READER
  773.     s->buffer_ptr = (uint8_t*)((intptr_t)buffer&(~1));

libavcodec/bitstream.h:781:1: return from a call to init_get_bits
  779.     skip_bits_long(s, 0);
  780. #endif
  781. }
       ^
  782. 
  783. static inline void align_get_bits(GetBitContext *s)

libavcodec/mjpegbdec.c:54:5: 
52.     init_get_bits(&hgb, buf_ptr, /*buf_size*/(buf_end - buf_ptr)*8);
53. 
54.     skip_bits(&hgb, 32); /* reserved zeros */
        ^
55. 
56.     if (get_bits_long(&hgb, 32) != MKBETAG('m','j','p','g'))

libavcodec/bitstream.h:678:1: start of procedure skip_bits()
  676. }
  677. 
  678. static inline void skip_bits(GetBitContext *s, int n){
       ^
  679.  //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
  680.     OPEN_READER(re, s)

libavcodec/bitstream.h:680:5: 
  678. static inline void skip_bits(GetBitContext *s, int n){
  679.  //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
  680.     OPEN_READER(re, s)
           ^
  681.     UPDATE_CACHE(re, s)
  682.     LAST_SKIP_BITS(re, s, n)

libavcodec/bitstream.h:681:5: 
  679.  //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
  680.     OPEN_READER(re, s)
  681.     UPDATE_CACHE(re, s)
           ^
  682.     LAST_SKIP_BITS(re, s, n)
  683.     CLOSE_READER(re, s)
