libavformat/spdifenc.c:204: error: Null Dereference
  pointer `&gbc->buffer` last assigned on line 203 could be null and is dereferenced by call to `ff_aac_parse_header()` at line 204, column 11.

libavformat/spdifenc.c:196:1: start of procedure spdif_header_aac()
194. }
195. 
196. static int spdif_header_aac(AVFormatContext *s, AVPacket *pkt)
     ^
197. {
198.     IEC61937Context *ctx = s->priv_data;

libavformat/spdifenc.c:198:5: 
196. static int spdif_header_aac(AVFormatContext *s, AVPacket *pkt)
197. {
198.     IEC61937Context *ctx = s->priv_data;
         ^
199.     AACADTSHeaderInfo hdr;
200.     GetBitContext gbc;

libavformat/spdifenc.c:203:5: 
201.     int ret;
202. 
203.     init_get_bits(&gbc, pkt->data, AAC_ADTS_HEADER_SIZE * 8);
         ^
204.     ret = ff_aac_parse_header(&gbc, &hdr);
205.     if (ret < 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)

libavformat/spdifenc.c:204:5: 
202. 
203.     init_get_bits(&gbc, pkt->data, AAC_ADTS_HEADER_SIZE * 8);
204.     ret = ff_aac_parse_header(&gbc, &hdr);
         ^
205.     if (ret < 0) {
206.         av_log(s, AV_LOG_ERROR, "Wrong AAC file format\n");

libavcodec/aacadtsdec.c:29:1: start of procedure ff_aac_parse_header()
  27. #include "mpeg4audio.h"
  28. 
  29. int ff_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr)
      ^
  30. {
  31.     int size, rdb, ch, sr;

libavcodec/aacadtsdec.c:34:8: 
  32.     int aot, crc_abs;
  33. 
  34.     if(get_bits(gbc, 12) != 0xfff)
             ^
  35.         return AAC_AC3_PARSE_ERROR_SYNC;
  36. 

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/aacadtsdec.c:34:8: Taking false branch
  32.     int aot, crc_abs;
  33. 
  34.     if(get_bits(gbc, 12) != 0xfff)
             ^
  35.         return AAC_AC3_PARSE_ERROR_SYNC;
  36. 

libavcodec/aacadtsdec.c:37:5: 
  35.         return AAC_AC3_PARSE_ERROR_SYNC;
  36. 
  37.     skip_bits1(gbc);             /* id */
          ^
  38.     skip_bits(gbc, 2);           /* layer */
  39.     crc_abs = get_bits1(gbc);    /* protection_absent */

libavcodec/get_bits.h:335:1: start of procedure skip_bits1()
    333. }
    334. 
    335. static inline void skip_bits1(GetBitContext *s){
         ^
    336.     skip_bits(s, 1);
    337. }

libavcodec/get_bits.h:336:5: 
    334. 
    335. static inline void skip_bits1(GetBitContext *s){
    336.     skip_bits(s, 1);
             ^
    337. }
    338. 

libavcodec/get_bits.h:303:1: start of procedure skip_bits()
      301. }
      302. 
      303. static inline void skip_bits(GetBitContext *s, int n){
           ^
      304.  //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
      305.     OPEN_READER(re, s);

libavcodec/get_bits.h:305:5: 
      303. static inline void skip_bits(GetBitContext *s, int n){
      304.  //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
      305.     OPEN_READER(re, s);
               ^
      306.     UPDATE_CACHE(re, s);
      307.     LAST_SKIP_BITS(re, s, n);

libavcodec/get_bits.h:306:5: 
      304.  //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
      305.     OPEN_READER(re, s);
      306.     UPDATE_CACHE(re, s);
               ^
      307.     LAST_SKIP_BITS(re, s, n);
      308.     CLOSE_READER(re, s);

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:307:5: 
      305.     OPEN_READER(re, s);
      306.     UPDATE_CACHE(re, s);
      307.     LAST_SKIP_BITS(re, s, n);
               ^
      308.     CLOSE_READER(re, s);
      309. }

libavcodec/get_bits.h:308:5: 
      306.     UPDATE_CACHE(re, s);
      307.     LAST_SKIP_BITS(re, s, n);
      308.     CLOSE_READER(re, s);
               ^
      309. }
      310. 

libavcodec/get_bits.h:309:1: return from a call to skip_bits
      307.     LAST_SKIP_BITS(re, s, n);
      308.     CLOSE_READER(re, s);
      309. }
           ^
      310. 
      311. static inline unsigned int get_bits1(GetBitContext *s){

libavcodec/get_bits.h:337:1: return from a call to skip_bits1
    335. static inline void skip_bits1(GetBitContext *s){
    336.     skip_bits(s, 1);
    337. }
         ^
    338. 
    339. /**

libavcodec/aacadtsdec.c:38:5: 
  36. 
  37.     skip_bits1(gbc);             /* id */
  38.     skip_bits(gbc, 2);           /* layer */
          ^
  39.     crc_abs = get_bits1(gbc);    /* protection_absent */
  40.     aot     = get_bits(gbc, 2);  /* profile_objecttype */

libavcodec/get_bits.h:303:1: start of procedure skip_bits()
    301. }
    302. 
    303. static inline void skip_bits(GetBitContext *s, int n){
         ^
    304.  //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
    305.     OPEN_READER(re, s);

libavcodec/get_bits.h:305:5: 
    303. static inline void skip_bits(GetBitContext *s, int n){
    304.  //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
    305.     OPEN_READER(re, s);
             ^
    306.     UPDATE_CACHE(re, s);
    307.     LAST_SKIP_BITS(re, s, n);

libavcodec/get_bits.h:306:5: 
    304.  //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
    305.     OPEN_READER(re, s);
    306.     UPDATE_CACHE(re, s);
             ^
    307.     LAST_SKIP_BITS(re, s, n);
    308.     CLOSE_READER(re, s);

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:307:5: 
    305.     OPEN_READER(re, s);
    306.     UPDATE_CACHE(re, s);
    307.     LAST_SKIP_BITS(re, s, n);
             ^
    308.     CLOSE_READER(re, s);
    309. }

libavcodec/get_bits.h:308:5: 
    306.     UPDATE_CACHE(re, s);
    307.     LAST_SKIP_BITS(re, s, n);
    308.     CLOSE_READER(re, s);
             ^
    309. }
    310. 

libavcodec/get_bits.h:309:1: return from a call to skip_bits
    307.     LAST_SKIP_BITS(re, s, n);
    308.     CLOSE_READER(re, s);
    309. }
         ^
    310. 
    311. static inline unsigned int get_bits1(GetBitContext *s){

libavcodec/aacadtsdec.c:39:5: 
  37.     skip_bits1(gbc);             /* id */
  38.     skip_bits(gbc, 2);           /* layer */
  39.     crc_abs = get_bits1(gbc);    /* protection_absent */
          ^
  40.     aot     = get_bits(gbc, 2);  /* profile_objecttype */
  41.     sr      = get_bits(gbc, 4);  /* sample_frequency_index */

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 spdif_header_aac(AVFormatContext *s, AVPacket *pkt)
{
    IEC61937Context *ctx = s->priv_data;
    AACADTSHeaderInfo hdr;
    GetBitContext gbc;
    int ret;
    init_get_bits(&gbc, pkt->data, AAC_ADTS_HEADER_SIZE * 8);
    ret = ff_aac_parse_header(&gbc, &hdr);
    if (ret < 0) {
        av_log(s, AV_LOG_ERROR, "Wrong AAC file format\n");
        return AVERROR_INVALIDDATA;
    }
    ctx->pkt_offset = hdr.samples << 2;
    switch (hdr.num_aac_frames) {
    case 1:
        ctx->data_type = IEC61937_MPEG2_AAC;
        break;
    case 2:
        ctx->data_type = IEC61937_MPEG2_AAC_LSF_2048;
        break;
    case 4:
        ctx->data_type = IEC61937_MPEG2_AAC_LSF_4096;
        break;
    default:
        av_log(s, AV_LOG_ERROR, "%i samples in AAC frame not supported\n",
               hdr.samples);
        return AVERROR(EINVAL);
    }
    return 0;
}
['static int spdif_header_aac(AVFormatContext *s, AVPacket *pkt)\n{\n    IEC61937Context *ctx = s->priv_data;\n    AACADTSHeaderInfo hdr;\n    GetBitContext gbc;\n    int ret;\n    init_get_bits(&gbc, pkt->data, AAC_ADTS_HEADER_SIZE * 8);\n    ret = ff_aac_parse_header(&gbc, &hdr);\n    if (ret < 0) {\n        av_log(s, AV_LOG_ERROR, "Wrong AAC file format\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    ctx->pkt_offset = hdr.samples << 2;\n    switch (hdr.num_aac_frames) {\n    case 1:\n        ctx->data_type = IEC61937_MPEG2_AAC;\n        break;\n    case 2:\n        ctx->data_type = IEC61937_MPEG2_AAC_LSF_2048;\n        break;\n    case 4:\n        ctx->data_type = IEC61937_MPEG2_AAC_LSF_4096;\n        break;\n    default:\n        av_log(s, AV_LOG_ERROR, "%i samples in AAC frame not supported\\n",\n               hdr.samples);\n        return AVERROR(EINVAL);\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}', 'int ff_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr)\n{\n    int size, rdb, ch, sr;\n    int aot, crc_abs;\n    if(get_bits(gbc, 12) != 0xfff)\n        return AAC_AC3_PARSE_ERROR_SYNC;\n    skip_bits1(gbc);\n    skip_bits(gbc, 2);\n    crc_abs = get_bits1(gbc);\n    aot     = get_bits(gbc, 2);\n    sr      = get_bits(gbc, 4);\n    if(!ff_mpeg4audio_sample_rates[sr])\n        return AAC_AC3_PARSE_ERROR_SAMPLE_RATE;\n    skip_bits1(gbc);\n    ch      = get_bits(gbc, 3);\n    skip_bits1(gbc);\n    skip_bits1(gbc);\n    skip_bits1(gbc);\n    skip_bits1(gbc);\n    size    = get_bits(gbc, 13);\n    if(size < AAC_ADTS_HEADER_SIZE)\n        return AAC_AC3_PARSE_ERROR_FRAME_SIZE;\n    skip_bits(gbc, 11);\n    rdb = get_bits(gbc, 2);\n    hdr->object_type    = aot + 1;\n    hdr->chan_config    = ch;\n    hdr->crc_absent     = crc_abs;\n    hdr->num_aac_frames = rdb + 1;\n    hdr->sampling_index = sr;\n    hdr->sample_rate    = ff_mpeg4audio_sample_rates[sr];\n    hdr->samples        = (rdb + 1) * 1024;\n    hdr->bit_rate       = size * 8 * hdr->sample_rate / hdr->samples;\n    return size;\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}', 'static inline void skip_bits1(GetBitContext *s){\n    skip_bits(s, 1);\n}', 'static inline void skip_bits(GetBitContext *s, int n){\n    OPEN_READER(re, s);\n    UPDATE_CACHE(re, s);\n    LAST_SKIP_BITS(re, s, n);\n    CLOSE_READER(re, s);\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}']