libavformat/rtpdec_jpeg.c:114: error: Null Dereference
  pointer `&pbc->buf_ptr` last assigned on line 104 could be null and is dereferenced by call to `put_marker()` at line 114, column 5.

libavformat/rtpdec_jpeg.c:99:1: start of procedure jpeg_create_header()
 97. }
 98. 
 99. static int jpeg_create_header(uint8_t *buf, int size, uint32_t type, uint32_t w,
     ^
100.                               uint32_t h, const uint8_t *qtable, int nb_qtable)
101. {

libavformat/rtpdec_jpeg.c:104:5: 
102.     PutBitContext pbc;
103. 
104.     init_put_bits(&pbc, buf, size);
         ^
105. 
106.     /* Convert from blocks to pixels. */

libavcodec/put_bits.h:52:1: start of procedure init_put_bits()
  50.  * @param buffer_size the size in bytes of buffer
  51.  */
  52. static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
      ^
  53. {
  54.     if(buffer_size < 0) {

libavcodec/put_bits.h:54:8: Taking true branch
  52. static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
  53. {
  54.     if(buffer_size < 0) {
             ^
  55.         buffer_size = 0;
  56.         buffer = NULL;

libavcodec/put_bits.h:55:9: 
  53. {
  54.     if(buffer_size < 0) {
  55.         buffer_size = 0;
              ^
  56.         buffer = NULL;
  57.     }

libavcodec/put_bits.h:56:9: 
  54.     if(buffer_size < 0) {
  55.         buffer_size = 0;
  56.         buffer = NULL;
              ^
  57.     }
  58. 

libavcodec/put_bits.h:59:5: 
  57.     }
  58. 
  59.     s->size_in_bits= 8*buffer_size;
          ^
  60.     s->buf = buffer;
  61.     s->buf_end = s->buf + buffer_size;

libavcodec/put_bits.h:60:5: 
  58. 
  59.     s->size_in_bits= 8*buffer_size;
  60.     s->buf = buffer;
          ^
  61.     s->buf_end = s->buf + buffer_size;
  62.     s->buf_ptr = s->buf;

libavcodec/put_bits.h:61:5: 
  59.     s->size_in_bits= 8*buffer_size;
  60.     s->buf = buffer;
  61.     s->buf_end = s->buf + buffer_size;
          ^
  62.     s->buf_ptr = s->buf;
  63.     s->bit_left=32;

libavcodec/put_bits.h:62:5: 
  60.     s->buf = buffer;
  61.     s->buf_end = s->buf + buffer_size;
  62.     s->buf_ptr = s->buf;
          ^
  63.     s->bit_left=32;
  64.     s->bit_buf=0;

libavcodec/put_bits.h:63:5: 
  61.     s->buf_end = s->buf + buffer_size;
  62.     s->buf_ptr = s->buf;
  63.     s->bit_left=32;
          ^
  64.     s->bit_buf=0;
  65. }

libavcodec/put_bits.h:64:5: 
  62.     s->buf_ptr = s->buf;
  63.     s->bit_left=32;
  64.     s->bit_buf=0;
          ^
  65. }
  66. 

libavcodec/put_bits.h:65:1: return from a call to init_put_bits
  63.     s->bit_left=32;
  64.     s->bit_buf=0;
  65. }
      ^
  66. 
  67. /**

libavformat/rtpdec_jpeg.c:107:5: 
105. 
106.     /* Convert from blocks to pixels. */
107.     w <<= 3;
         ^
108.     h <<= 3;
109. 

libavformat/rtpdec_jpeg.c:108:5: 
106.     /* Convert from blocks to pixels. */
107.     w <<= 3;
108.     h <<= 3;
         ^
109. 
110.     /* SOI */

libavformat/rtpdec_jpeg.c:111:5: 
109. 
110.     /* SOI */
111.     put_marker(&pbc, SOI);
         ^
112. 
113.     /* JFIF header */

libavcodec/mjpeg.h:122:1: start of procedure put_marker()
  120. } JPEG_MARKER;
  121. 
  122. static inline void put_marker(PutBitContext *p, int code)
       ^
  123. {
  124.     put_bits(p, 8, 0xff);

libavcodec/mjpeg.h:124:5: 
  122. static inline void put_marker(PutBitContext *p, int code)
  123. {
  124.     put_bits(p, 8, 0xff);
           ^
  125.     put_bits(p, 8, code);
  126. }

libavcodec/put_bits.h:128:1: start of procedure put_bits()
    126.  * Use put_bits32 to write 32 bits.
    127.  */
    128. static inline void put_bits(PutBitContext *s, int n, unsigned int value)
         ^
    129. {
    130.     unsigned int bit_buf;

libavcodec/put_bits.h:134:5: 
    132. 
    133.     //    printf("put_bits=%d %x\n", n, value);
    134.     assert(n <= 31 && value < (1U << n));
             ^
    135. 
    136.     bit_buf = s->bit_buf;

libavcodec/put_bits.h:136:5: 
    134.     assert(n <= 31 && value < (1U << n));
    135. 
    136.     bit_buf = s->bit_buf;
             ^
    137.     bit_left = s->bit_left;
    138. 

libavcodec/put_bits.h:137:5: 
    135. 
    136.     bit_buf = s->bit_buf;
    137.     bit_left = s->bit_left;
             ^
    138. 
    139.     //    printf("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt, bit_buf);

libavcodec/put_bits.h:151:9: Taking true branch
    149.     bit_left-=n;
    150. #else
    151.     if (n < bit_left) {
                 ^
    152.         bit_buf = (bit_buf<<n) | value;
    153.         bit_left-=n;

libavcodec/put_bits.h:152:9: 
    150. #else
    151.     if (n < bit_left) {
    152.         bit_buf = (bit_buf<<n) | value;
                 ^
    153.         bit_left-=n;
    154.     } else {

libavcodec/put_bits.h:153:9: 
    151.     if (n < bit_left) {
    152.         bit_buf = (bit_buf<<n) | value;
    153.         bit_left-=n;
                 ^
    154.     } else {
    155.         bit_buf<<=bit_left;

libavcodec/put_bits.h:165:5: 
    163. #endif
    164. 
    165.     s->bit_buf = bit_buf;
             ^
    166.     s->bit_left = bit_left;
    167. }

libavcodec/put_bits.h:166:5: 
    164. 
    165.     s->bit_buf = bit_buf;
    166.     s->bit_left = bit_left;
             ^
    167. }
    168. 

libavcodec/put_bits.h:167:1: return from a call to put_bits
    165.     s->bit_buf = bit_buf;
    166.     s->bit_left = bit_left;
    167. }
         ^
    168. 
    169. static inline void put_sbits(PutBitContext *pb, int n, int32_t value)

libavcodec/mjpeg.h:125:5: 
  123. {
  124.     put_bits(p, 8, 0xff);
  125.     put_bits(p, 8, code);
           ^
  126. }
  127. 

libavcodec/put_bits.h:128:1: start of procedure put_bits()
    126.  * Use put_bits32 to write 32 bits.
    127.  */
    128. static inline void put_bits(PutBitContext *s, int n, unsigned int value)
         ^
    129. {
    130.     unsigned int bit_buf;

libavcodec/put_bits.h:134:5: 
    132. 
    133.     //    printf("put_bits=%d %x\n", n, value);
    134.     assert(n <= 31 && value < (1U << n));
             ^
    135. 
    136.     bit_buf = s->bit_buf;

libavcodec/put_bits.h:136:5: 
    134.     assert(n <= 31 && value < (1U << n));
    135. 
    136.     bit_buf = s->bit_buf;
             ^
    137.     bit_left = s->bit_left;
    138. 

libavcodec/put_bits.h:137:5: 
    135. 
    136.     bit_buf = s->bit_buf;
    137.     bit_left = s->bit_left;
             ^
    138. 
    139.     //    printf("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt, bit_buf);

libavcodec/put_bits.h:151:9: Taking true branch
    149.     bit_left-=n;
    150. #else
    151.     if (n < bit_left) {
                 ^
    152.         bit_buf = (bit_buf<<n) | value;
    153.         bit_left-=n;

libavcodec/put_bits.h:152:9: 
    150. #else
    151.     if (n < bit_left) {
    152.         bit_buf = (bit_buf<<n) | value;
                 ^
    153.         bit_left-=n;
    154.     } else {

libavcodec/put_bits.h:153:9: 
    151.     if (n < bit_left) {
    152.         bit_buf = (bit_buf<<n) | value;
    153.         bit_left-=n;
                 ^
    154.     } else {
    155.         bit_buf<<=bit_left;

libavcodec/put_bits.h:165:5: 
    163. #endif
    164. 
    165.     s->bit_buf = bit_buf;
             ^
    166.     s->bit_left = bit_left;
    167. }

libavcodec/put_bits.h:166:5: 
    164. 
    165.     s->bit_buf = bit_buf;
    166.     s->bit_left = bit_left;
             ^
    167. }
    168. 

libavcodec/put_bits.h:167:1: return from a call to put_bits
    165.     s->bit_buf = bit_buf;
    166.     s->bit_left = bit_left;
    167. }
         ^
    168. 
    169. static inline void put_sbits(PutBitContext *pb, int n, int32_t value)

libavcodec/mjpeg.h:126:1: return from a call to put_marker
  124.     put_bits(p, 8, 0xff);
  125.     put_bits(p, 8, code);
  126. }
       ^
  127. 
  128. #define PREDICT(ret, topleft, top, left, predictor)\

libavformat/rtpdec_jpeg.c:114:5: 
112. 
113.     /* JFIF header */
114.     put_marker(&pbc, APP0);
         ^
115.     put_bits(&pbc, 16, 16);
116.     avpriv_put_string(&pbc, "JFIF", 1);

libavcodec/mjpeg.h:122:1: start of procedure put_marker()
  120. } JPEG_MARKER;
  121. 
  122. static inline void put_marker(PutBitContext *p, int code)
       ^
  123. {
  124.     put_bits(p, 8, 0xff);

libavcodec/mjpeg.h:124:5: 
  122. static inline void put_marker(PutBitContext *p, int code)
  123. {
  124.     put_bits(p, 8, 0xff);
           ^
  125.     put_bits(p, 8, code);
  126. }

libavcodec/put_bits.h:128:1: start of procedure put_bits()
    126.  * Use put_bits32 to write 32 bits.
    127.  */
    128. static inline void put_bits(PutBitContext *s, int n, unsigned int value)
         ^
    129. {
    130.     unsigned int bit_buf;

libavcodec/put_bits.h:134:5: 
    132. 
    133.     //    printf("put_bits=%d %x\n", n, value);
    134.     assert(n <= 31 && value < (1U << n));
             ^
    135. 
    136.     bit_buf = s->bit_buf;

libavcodec/put_bits.h:136:5: 
    134.     assert(n <= 31 && value < (1U << n));
    135. 
    136.     bit_buf = s->bit_buf;
             ^
    137.     bit_left = s->bit_left;
    138. 

libavcodec/put_bits.h:137:5: 
    135. 
    136.     bit_buf = s->bit_buf;
    137.     bit_left = s->bit_left;
             ^
    138. 
    139.     //    printf("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt, bit_buf);

libavcodec/put_bits.h:151:9: Taking false branch
    149.     bit_left-=n;
    150. #else
    151.     if (n < bit_left) {
                 ^
    152.         bit_buf = (bit_buf<<n) | value;
    153.         bit_left-=n;

libavcodec/put_bits.h:155:9: 
    153.         bit_left-=n;
    154.     } else {
    155.         bit_buf<<=bit_left;
                 ^
    156.         bit_buf |= value >> (n - bit_left);
    157.         AV_WB32(s->buf_ptr, bit_buf);

libavcodec/put_bits.h:156:9: 
    154.     } else {
    155.         bit_buf<<=bit_left;
    156.         bit_buf |= value >> (n - bit_left);
                 ^
    157.         AV_WB32(s->buf_ptr, bit_buf);
    158.         //printf("bitbuf = %08x\n", bit_buf);

libavcodec/put_bits.h:157:9: 
    155.         bit_buf<<=bit_left;
    156.         bit_buf |= value >> (n - bit_left);
    157.         AV_WB32(s->buf_ptr, bit_buf);
                 ^
    158.         //printf("bitbuf = %08x\n", bit_buf);
    159.         s->buf_ptr+=4;

static int jpeg_create_header(uint8_t *buf, int size, uint32_t type, uint32_t w,
                              uint32_t h, const uint8_t *qtable, int nb_qtable)
{
    PutBitContext pbc;
    init_put_bits(&pbc, buf, size);
    w <<= 3;
    h <<= 3;
    put_marker(&pbc, SOI);
    put_marker(&pbc, APP0);
    put_bits(&pbc, 16, 16);
    avpriv_put_string(&pbc, "JFIF", 1);
    put_bits(&pbc, 16, 0x0201);
    put_bits(&pbc, 8, 0);
    put_bits(&pbc, 16, 1);
    put_bits(&pbc, 16, 1);
    put_bits(&pbc, 8, 0);
    put_bits(&pbc, 8, 0);
    put_marker(&pbc, DQT);
    if (nb_qtable == 2) {
        put_bits(&pbc, 16, 2 + 2 * (1 + 64));
    } else {
        put_bits(&pbc, 16, 2 + 1 * (1 + 64));
    }
    put_bits(&pbc, 8, 0);
    avpriv_copy_bits(&pbc, qtable, 64 * 8);
    if (nb_qtable == 2) {
        put_bits(&pbc, 8, 1);
        avpriv_copy_bits(&pbc, qtable + 64, 64 * 8);
    }
    put_marker(&pbc, DHT);
    jpeg_create_huffman_table(&pbc, 0, 0, avpriv_mjpeg_bits_dc_luminance,
                              avpriv_mjpeg_val_dc);
    jpeg_create_huffman_table(&pbc, 0, 1, avpriv_mjpeg_bits_dc_chrominance,
                              avpriv_mjpeg_val_dc);
    jpeg_create_huffman_table(&pbc, 1, 0, avpriv_mjpeg_bits_ac_luminance,
                              avpriv_mjpeg_val_ac_luminance);
    jpeg_create_huffman_table(&pbc, 1, 1, avpriv_mjpeg_bits_ac_chrominance,
                              avpriv_mjpeg_val_ac_chrominance);
    put_marker(&pbc, SOF0);
    put_bits(&pbc, 16, 17);
    put_bits(&pbc, 8, 8);
    put_bits(&pbc, 8, h >> 8);
    put_bits(&pbc, 8, h);
    put_bits(&pbc, 8, w >> 8);
    put_bits(&pbc, 8, w);
    put_bits(&pbc, 8, 3);
    put_bits(&pbc, 8, 1);
    put_bits(&pbc, 8, type ? 34 : 33);
    put_bits(&pbc, 8, 0);
    put_bits(&pbc, 8, 2);
    put_bits(&pbc, 8, 17);
    put_bits(&pbc, 8, nb_qtable == 2 ? 1 : 0);
    put_bits(&pbc, 8, 3);
    put_bits(&pbc, 8, 17);
    put_bits(&pbc, 8, nb_qtable == 2 ? 1 : 0);
    put_marker(&pbc, SOS);
    put_bits(&pbc, 16, 12);
    put_bits(&pbc, 8, 3);
    put_bits(&pbc, 8, 1);
    put_bits(&pbc, 8, 0);
    put_bits(&pbc, 8, 2);
    put_bits(&pbc, 8, 17);
    put_bits(&pbc, 8, 3);
    put_bits(&pbc, 8, 17);
    put_bits(&pbc, 8, 0);
    put_bits(&pbc, 8, 63);
    put_bits(&pbc, 8, 0);
    flush_put_bits(&pbc);
    return put_bits_count(&pbc) / 8;
}
['static int jpeg_create_header(uint8_t *buf, int size, uint32_t type, uint32_t w,\n                              uint32_t h, const uint8_t *qtable, int nb_qtable)\n{\n    PutBitContext pbc;\n    init_put_bits(&pbc, buf, size);\n    w <<= 3;\n    h <<= 3;\n    put_marker(&pbc, SOI);\n    put_marker(&pbc, APP0);\n    put_bits(&pbc, 16, 16);\n    avpriv_put_string(&pbc, "JFIF", 1);\n    put_bits(&pbc, 16, 0x0201);\n    put_bits(&pbc, 8, 0);\n    put_bits(&pbc, 16, 1);\n    put_bits(&pbc, 16, 1);\n    put_bits(&pbc, 8, 0);\n    put_bits(&pbc, 8, 0);\n    put_marker(&pbc, DQT);\n    if (nb_qtable == 2) {\n        put_bits(&pbc, 16, 2 + 2 * (1 + 64));\n    } else {\n        put_bits(&pbc, 16, 2 + 1 * (1 + 64));\n    }\n    put_bits(&pbc, 8, 0);\n    avpriv_copy_bits(&pbc, qtable, 64 * 8);\n    if (nb_qtable == 2) {\n        put_bits(&pbc, 8, 1);\n        avpriv_copy_bits(&pbc, qtable + 64, 64 * 8);\n    }\n    put_marker(&pbc, DHT);\n    jpeg_create_huffman_table(&pbc, 0, 0, avpriv_mjpeg_bits_dc_luminance,\n                              avpriv_mjpeg_val_dc);\n    jpeg_create_huffman_table(&pbc, 0, 1, avpriv_mjpeg_bits_dc_chrominance,\n                              avpriv_mjpeg_val_dc);\n    jpeg_create_huffman_table(&pbc, 1, 0, avpriv_mjpeg_bits_ac_luminance,\n                              avpriv_mjpeg_val_ac_luminance);\n    jpeg_create_huffman_table(&pbc, 1, 1, avpriv_mjpeg_bits_ac_chrominance,\n                              avpriv_mjpeg_val_ac_chrominance);\n    put_marker(&pbc, SOF0);\n    put_bits(&pbc, 16, 17);\n    put_bits(&pbc, 8, 8);\n    put_bits(&pbc, 8, h >> 8);\n    put_bits(&pbc, 8, h);\n    put_bits(&pbc, 8, w >> 8);\n    put_bits(&pbc, 8, w);\n    put_bits(&pbc, 8, 3);\n    put_bits(&pbc, 8, 1);\n    put_bits(&pbc, 8, type ? 34 : 33);\n    put_bits(&pbc, 8, 0);\n    put_bits(&pbc, 8, 2);\n    put_bits(&pbc, 8, 17);\n    put_bits(&pbc, 8, nb_qtable == 2 ? 1 : 0);\n    put_bits(&pbc, 8, 3);\n    put_bits(&pbc, 8, 17);\n    put_bits(&pbc, 8, nb_qtable == 2 ? 1 : 0);\n    put_marker(&pbc, SOS);\n    put_bits(&pbc, 16, 12);\n    put_bits(&pbc, 8, 3);\n    put_bits(&pbc, 8, 1);\n    put_bits(&pbc, 8, 0);\n    put_bits(&pbc, 8, 2);\n    put_bits(&pbc, 8, 17);\n    put_bits(&pbc, 8, 3);\n    put_bits(&pbc, 8, 17);\n    put_bits(&pbc, 8, 0);\n    put_bits(&pbc, 8, 63);\n    put_bits(&pbc, 8, 0);\n    flush_put_bits(&pbc);\n    return put_bits_count(&pbc) / 8;\n}', 'static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)\n{\n    if(buffer_size < 0) {\n        buffer_size = 0;\n        buffer = NULL;\n    }\n    s->size_in_bits= 8*buffer_size;\n    s->buf = buffer;\n    s->buf_end = s->buf + buffer_size;\n    s->buf_ptr = s->buf;\n    s->bit_left=32;\n    s->bit_buf=0;\n}', 'static inline void put_marker(PutBitContext *p, int code)\n{\n    put_bits(p, 8, 0xff);\n    put_bits(p, 8, code);\n}', 'static inline void put_bits(PutBitContext *s, int n, unsigned int value)\n{\n    unsigned int bit_buf;\n    int bit_left;\n    assert(n <= 31 && value < (1U << n));\n    bit_buf = s->bit_buf;\n    bit_left = s->bit_left;\n#ifdef BITSTREAM_WRITER_LE\n    bit_buf |= value << (32 - bit_left);\n    if (n >= bit_left) {\n        AV_WL32(s->buf_ptr, bit_buf);\n        s->buf_ptr+=4;\n        bit_buf = (bit_left==32)?0:value >> bit_left;\n        bit_left+=32;\n    }\n    bit_left-=n;\n#else\n    if (n < bit_left) {\n        bit_buf = (bit_buf<<n) | value;\n        bit_left-=n;\n    } else {\n        bit_buf<<=bit_left;\n        bit_buf |= value >> (n - bit_left);\n        AV_WB32(s->buf_ptr, bit_buf);\n        s->buf_ptr+=4;\n        bit_left+=32 - n;\n        bit_buf = value;\n    }\n#endif\n    s->bit_buf = bit_buf;\n    s->bit_left = bit_left;\n}']