libavformat/adtsenc.c:85: error: Buffer Overrun L2
  Offset: [3, 59] (⇐ [0, 56] + 3) Size: 7 by call to `put_bits`.

libavformat/adtsenc.c:60:1: Array declaration
58. }
59. 
60. static int adts_write_frame_header(AVFormatContext *s, int size)
    ^
61. {
62.     ADTSContext *ctx = s->priv_data;

libavformat/adtsenc.c:66:5: Call
64.     uint8_t buf[ADTS_HEADER_SIZE];
65. 
66.     init_put_bits(&pb, buf, ADTS_HEADER_SIZE);
        ^
67. 
68.     /* adts_fixed_header */

libavcodec/bitstream.h:90:1: Parameter `*buffer`
  88. } PutBitContext;
  89. 
  90. static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
      ^
  91. {
  92.     if(buffer_size < 0) {

libavcodec/bitstream.h:97:5: Assignment
  95.     }
  96. 
  97.     s->buf = buffer;
          ^
  98.     s->buf_end = s->buf + buffer_size;
  99. #ifdef ALT_BITSTREAM_WRITER

libavcodec/bitstream.h:104:5: Assignment
  102. //    memset(buffer, 0, buffer_size);
  103. #else
  104.     s->buf_ptr = s->buf;
           ^
  105.     s->bit_left=32;
  106.     s->bit_buf=0;

libavformat/adtsenc.c:69:5: Call
67. 
68.     /* adts_fixed_header */
69.     put_bits(&pb, 12, 0xfff);   /* syncword */
        ^
70.     put_bits(&pb, 1, 0);        /* ID */
71.     put_bits(&pb, 2, 0);        /* layer */

libavcodec/bitstream.h:183:1: Parameter `*s->buf_ptr`
  181. 
  182. #ifndef ALT_BITSTREAM_WRITER
  183. static inline void put_bits(PutBitContext *s, int n, unsigned int value)
       ^
  184. {
  185.     unsigned int bit_buf;

libavformat/adtsenc.c:70:5: Call
68.     /* adts_fixed_header */
69.     put_bits(&pb, 12, 0xfff);   /* syncword */
70.     put_bits(&pb, 1, 0);        /* ID */
        ^
71.     put_bits(&pb, 2, 0);        /* layer */
72.     put_bits(&pb, 1, 1);        /* protection_absent */

libavcodec/bitstream.h:183:1: Parameter `*s->buf_ptr`
  181. 
  182. #ifndef ALT_BITSTREAM_WRITER
  183. static inline void put_bits(PutBitContext *s, int n, unsigned int value)
       ^
  184. {
  185.     unsigned int bit_buf;

libavformat/adtsenc.c:71:5: Call
69.     put_bits(&pb, 12, 0xfff);   /* syncword */
70.     put_bits(&pb, 1, 0);        /* ID */
71.     put_bits(&pb, 2, 0);        /* layer */
        ^
72.     put_bits(&pb, 1, 1);        /* protection_absent */
73.     put_bits(&pb, 2, ctx->objecttype); /* profile_objecttype */

libavcodec/bitstream.h:183:1: Parameter `*s->buf_ptr`
  181. 
  182. #ifndef ALT_BITSTREAM_WRITER
  183. static inline void put_bits(PutBitContext *s, int n, unsigned int value)
       ^
  184. {
  185.     unsigned int bit_buf;

libavformat/adtsenc.c:72:5: Call
70.     put_bits(&pb, 1, 0);        /* ID */
71.     put_bits(&pb, 2, 0);        /* layer */
72.     put_bits(&pb, 1, 1);        /* protection_absent */
        ^
73.     put_bits(&pb, 2, ctx->objecttype); /* profile_objecttype */
74.     put_bits(&pb, 4, ctx->sample_rate_index);

libavcodec/bitstream.h:183:1: Parameter `*s->buf_ptr`
  181. 
  182. #ifndef ALT_BITSTREAM_WRITER
  183. static inline void put_bits(PutBitContext *s, int n, unsigned int value)
       ^
  184. {
  185.     unsigned int bit_buf;

libavformat/adtsenc.c:73:5: Call
71.     put_bits(&pb, 2, 0);        /* layer */
72.     put_bits(&pb, 1, 1);        /* protection_absent */
73.     put_bits(&pb, 2, ctx->objecttype); /* profile_objecttype */
        ^
74.     put_bits(&pb, 4, ctx->sample_rate_index);
75.     put_bits(&pb, 1, 0);        /* private_bit */

libavcodec/bitstream.h:183:1: Parameter `*s->buf_ptr`
  181. 
  182. #ifndef ALT_BITSTREAM_WRITER
  183. static inline void put_bits(PutBitContext *s, int n, unsigned int value)
       ^
  184. {
  185.     unsigned int bit_buf;

libavformat/adtsenc.c:74:5: Call
72.     put_bits(&pb, 1, 1);        /* protection_absent */
73.     put_bits(&pb, 2, ctx->objecttype); /* profile_objecttype */
74.     put_bits(&pb, 4, ctx->sample_rate_index);
        ^
75.     put_bits(&pb, 1, 0);        /* private_bit */
76.     put_bits(&pb, 3, ctx->channel_conf); /* channel_configuration */

libavcodec/bitstream.h:183:1: Parameter `*s->buf_ptr`
  181. 
  182. #ifndef ALT_BITSTREAM_WRITER
  183. static inline void put_bits(PutBitContext *s, int n, unsigned int value)
       ^
  184. {
  185.     unsigned int bit_buf;

libavformat/adtsenc.c:75:5: Call
73.     put_bits(&pb, 2, ctx->objecttype); /* profile_objecttype */
74.     put_bits(&pb, 4, ctx->sample_rate_index);
75.     put_bits(&pb, 1, 0);        /* private_bit */
        ^
76.     put_bits(&pb, 3, ctx->channel_conf); /* channel_configuration */
77.     put_bits(&pb, 1, 0);        /* original_copy */

libavcodec/bitstream.h:183:1: Parameter `*s->buf_ptr`
  181. 
  182. #ifndef ALT_BITSTREAM_WRITER
  183. static inline void put_bits(PutBitContext *s, int n, unsigned int value)
       ^
  184. {
  185.     unsigned int bit_buf;

libavformat/adtsenc.c:76:5: Call
74.     put_bits(&pb, 4, ctx->sample_rate_index);
75.     put_bits(&pb, 1, 0);        /* private_bit */
76.     put_bits(&pb, 3, ctx->channel_conf); /* channel_configuration */
        ^
77.     put_bits(&pb, 1, 0);        /* original_copy */
78.     put_bits(&pb, 1, 0);        /* home */

libavcodec/bitstream.h:183:1: Parameter `*s->buf_ptr`
  181. 
  182. #ifndef ALT_BITSTREAM_WRITER
  183. static inline void put_bits(PutBitContext *s, int n, unsigned int value)
       ^
  184. {
  185.     unsigned int bit_buf;

libavformat/adtsenc.c:77:5: Call
75.     put_bits(&pb, 1, 0);        /* private_bit */
76.     put_bits(&pb, 3, ctx->channel_conf); /* channel_configuration */
77.     put_bits(&pb, 1, 0);        /* original_copy */
        ^
78.     put_bits(&pb, 1, 0);        /* home */
79. 

libavcodec/bitstream.h:183:1: Parameter `*s->buf_ptr`
  181. 
  182. #ifndef ALT_BITSTREAM_WRITER
  183. static inline void put_bits(PutBitContext *s, int n, unsigned int value)
       ^
  184. {
  185.     unsigned int bit_buf;

libavformat/adtsenc.c:78:5: Call
76.     put_bits(&pb, 3, ctx->channel_conf); /* channel_configuration */
77.     put_bits(&pb, 1, 0);        /* original_copy */
78.     put_bits(&pb, 1, 0);        /* home */
        ^
79. 
80.     /* adts_variable_header */

libavcodec/bitstream.h:183:1: Parameter `*s->buf_ptr`
  181. 
  182. #ifndef ALT_BITSTREAM_WRITER
  183. static inline void put_bits(PutBitContext *s, int n, unsigned int value)
       ^
  184. {
  185.     unsigned int bit_buf;

libavformat/adtsenc.c:81:5: Call
79. 
80.     /* adts_variable_header */
81.     put_bits(&pb, 1, 0);        /* copyright_identification_bit */
        ^
82.     put_bits(&pb, 1, 0);        /* copyright_identification_start */
83.     put_bits(&pb, 13, ADTS_HEADER_SIZE + size); /* aac_frame_length */

libavcodec/bitstream.h:183:1: Parameter `*s->buf_ptr`
  181. 
  182. #ifndef ALT_BITSTREAM_WRITER
  183. static inline void put_bits(PutBitContext *s, int n, unsigned int value)
       ^
  184. {
  185.     unsigned int bit_buf;

libavformat/adtsenc.c:82:5: Call
80.     /* adts_variable_header */
81.     put_bits(&pb, 1, 0);        /* copyright_identification_bit */
82.     put_bits(&pb, 1, 0);        /* copyright_identification_start */
        ^
83.     put_bits(&pb, 13, ADTS_HEADER_SIZE + size); /* aac_frame_length */
84.     put_bits(&pb, 11, 0x7ff);   /* adts_buffer_fullness */

libavcodec/bitstream.h:183:1: Parameter `*s->buf_ptr`
  181. 
  182. #ifndef ALT_BITSTREAM_WRITER
  183. static inline void put_bits(PutBitContext *s, int n, unsigned int value)
       ^
  184. {
  185.     unsigned int bit_buf;

libavformat/adtsenc.c:83:5: Call
81.     put_bits(&pb, 1, 0);        /* copyright_identification_bit */
82.     put_bits(&pb, 1, 0);        /* copyright_identification_start */
83.     put_bits(&pb, 13, ADTS_HEADER_SIZE + size); /* aac_frame_length */
        ^
84.     put_bits(&pb, 11, 0x7ff);   /* adts_buffer_fullness */
85.     put_bits(&pb, 2, 0);        /* number_of_raw_data_blocks_in_frame */

libavcodec/bitstream.h:183:1: Parameter `*s->buf_ptr`
  181. 
  182. #ifndef ALT_BITSTREAM_WRITER
  183. static inline void put_bits(PutBitContext *s, int n, unsigned int value)
       ^
  184. {
  185.     unsigned int bit_buf;

libavformat/adtsenc.c:84:5: Call
82.     put_bits(&pb, 1, 0);        /* copyright_identification_start */
83.     put_bits(&pb, 13, ADTS_HEADER_SIZE + size); /* aac_frame_length */
84.     put_bits(&pb, 11, 0x7ff);   /* adts_buffer_fullness */
        ^
85.     put_bits(&pb, 2, 0);        /* number_of_raw_data_blocks_in_frame */
86. 

libavcodec/bitstream.h:183:1: Parameter `*s->buf_ptr`
  181. 
  182. #ifndef ALT_BITSTREAM_WRITER
  183. static inline void put_bits(PutBitContext *s, int n, unsigned int value)
       ^
  184. {
  185.     unsigned int bit_buf;

libavformat/adtsenc.c:85:5: Call
83.     put_bits(&pb, 13, ADTS_HEADER_SIZE + size); /* aac_frame_length */
84.     put_bits(&pb, 11, 0x7ff);   /* adts_buffer_fullness */
85.     put_bits(&pb, 2, 0);        /* number_of_raw_data_blocks_in_frame */
        ^
86. 
87.     flush_put_bits(&pb);

libavcodec/bitstream.h:183:1: <Length trace>
181. 
182. #ifndef ALT_BITSTREAM_WRITER
183. static inline void put_bits(PutBitContext *s, int n, unsigned int value)
     ^
184. {
185.     unsigned int bit_buf;

libavcodec/bitstream.h:183:1: Parameter `*s->buf_ptr`
  181. 
  182. #ifndef ALT_BITSTREAM_WRITER
  183. static inline void put_bits(PutBitContext *s, int n, unsigned int value)
       ^
  184. {
  185.     unsigned int bit_buf;

libavcodec/bitstream.h:225:13: Array access: Offset: [3, 59] (⇐ [0, 56] + 3) Size: 7 by call to `put_bits` 
  223.             s->buf_ptr[1] = bit_buf >> 16;
  224.             s->buf_ptr[2] = bit_buf >>  8;
  225.             s->buf_ptr[3] = bit_buf      ;
                   ^
  226.         } else
  227. #endif

static inline void put_bits(PutBitContext *s, int n, unsigned int value)
{
    unsigned int bit_buf;
    int bit_left;
    assert(n == 32 || value < (1U << n));
    bit_buf = s->bit_buf;
    bit_left = s->bit_left;
#ifdef BITSTREAM_WRITER_LE
    bit_buf |= value << (32 - bit_left);
    if (n >= bit_left) {
#ifndef HAVE_FAST_UNALIGNED
        if (3 & (intptr_t) s->buf_ptr) {
            s->buf_ptr[0] = bit_buf      ;
            s->buf_ptr[1] = bit_buf >>  8;
            s->buf_ptr[2] = bit_buf >> 16;
            s->buf_ptr[3] = bit_buf >> 24;
        } else
#endif
        *(uint32_t *)s->buf_ptr = le2me_32(bit_buf);
        s->buf_ptr+=4;
        bit_buf = (bit_left==32)?0:value >> bit_left;
        bit_left+=32;
    }
    bit_left-=n;
#else
    if (n < bit_left) {
        bit_buf = (bit_buf<<n) | value;
        bit_left-=n;
    } else {
        bit_buf<<=bit_left;
        bit_buf |= value >> (n - bit_left);
#ifndef HAVE_FAST_UNALIGNED
        if (3 & (intptr_t) s->buf_ptr) {
            s->buf_ptr[0] = bit_buf >> 24;
            s->buf_ptr[1] = bit_buf >> 16;
            s->buf_ptr[2] = bit_buf >>  8;
            s->buf_ptr[3] = bit_buf      ;
        } else
#endif
        *(uint32_t *)s->buf_ptr = be2me_32(bit_buf);
        s->buf_ptr+=4;
        bit_left+=32 - n;
        bit_buf = value;
    }
#endif
    s->bit_buf = bit_buf;
    s->bit_left = bit_left;
}
['static int adts_write_frame_header(AVFormatContext *s, int size)\n{\n    ADTSContext *ctx = s->priv_data;\n    PutBitContext pb;\n    uint8_t buf[ADTS_HEADER_SIZE];\n    init_put_bits(&pb, buf, ADTS_HEADER_SIZE);\n    put_bits(&pb, 12, 0xfff);\n    put_bits(&pb, 1, 0);\n    put_bits(&pb, 2, 0);\n    put_bits(&pb, 1, 1);\n    put_bits(&pb, 2, ctx->objecttype);\n    put_bits(&pb, 4, ctx->sample_rate_index);\n    put_bits(&pb, 1, 0);\n    put_bits(&pb, 3, ctx->channel_conf);\n    put_bits(&pb, 1, 0);\n    put_bits(&pb, 1, 0);\n    put_bits(&pb, 1, 0);\n    put_bits(&pb, 1, 0);\n    put_bits(&pb, 13, ADTS_HEADER_SIZE + size);\n    put_bits(&pb, 11, 0x7ff);\n    put_bits(&pb, 2, 0);\n    flush_put_bits(&pb);\n    put_buffer(s->pb, buf, ADTS_HEADER_SIZE);\n    return 0;\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->buf = buffer;\n    s->buf_end = s->buf + buffer_size;\n#ifdef ALT_BITSTREAM_WRITER\n    s->index=0;\n    ((uint32_t*)(s->buf))[0]=0;\n#else\n    s->buf_ptr = s->buf;\n    s->bit_left=32;\n    s->bit_buf=0;\n#endif\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 == 32 || 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#ifndef HAVE_FAST_UNALIGNED\n        if (3 & (intptr_t) s->buf_ptr) {\n            s->buf_ptr[0] = bit_buf      ;\n            s->buf_ptr[1] = bit_buf >>  8;\n            s->buf_ptr[2] = bit_buf >> 16;\n            s->buf_ptr[3] = bit_buf >> 24;\n        } else\n#endif\n        *(uint32_t *)s->buf_ptr = le2me_32(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#ifndef HAVE_FAST_UNALIGNED\n        if (3 & (intptr_t) s->buf_ptr) {\n            s->buf_ptr[0] = bit_buf >> 24;\n            s->buf_ptr[1] = bit_buf >> 16;\n            s->buf_ptr[2] = bit_buf >>  8;\n            s->buf_ptr[3] = bit_buf      ;\n        } else\n#endif\n        *(uint32_t *)s->buf_ptr = be2me_32(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}']