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

libavformat/spdif.c:188:1: start of procedure spdif_header_aac()
186. }
187. 
188. static int spdif_header_aac(AVFormatContext *s, AVPacket *pkt)
     ^
189. {
190.     IEC958Context *ctx = s->priv_data;

libavformat/spdif.c:190:5: 
188. static int spdif_header_aac(AVFormatContext *s, AVPacket *pkt)
189. {
190.     IEC958Context *ctx = s->priv_data;
         ^
191.     AACADTSHeaderInfo hdr;
192.     GetBitContext gbc;

libavformat/spdif.c:195:5: 
193.     int ret;
194. 
195.     init_get_bits(&gbc, pkt->data, AAC_ADTS_HEADER_SIZE * 8);
         ^
196.     ret = ff_aac_parse_header(&gbc, &hdr);
197.     if (ret < 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)

libavformat/spdif.c:196:5: 
194. 
195.     init_get_bits(&gbc, pkt->data, AAC_ADTS_HEADER_SIZE * 8);
196.     ret = ff_aac_parse_header(&gbc, &hdr);
         ^
197.     if (ret < 0) {
198.         av_log(s, AV_LOG_ERROR, "Wrong AAC file format\n");

libavcodec/aac_parser.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/aac_parser.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: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:60:1: start of procedure bswap_32()
      58. 
      59. #ifndef bswap_32
      60. static av_always_inline av_const uint32_t bswap_32(uint32_t x)
          ^
      61. {
      62.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);

libavutil/bswap.h:62:5: 
      60. static av_always_inline av_const uint32_t bswap_32(uint32_t x)
      61. {
      62.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
              ^
      63.     x= (x>>16) | (x<<16);
      64.     return x;

libavutil/bswap.h:63:5: 
      61. {
      62.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
      63.     x= (x>>16) | (x<<16);
              ^
      64.     return x;
      65. }

libavutil/bswap.h:64:5: 
      62.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
      63.     x= (x>>16) | (x<<16);
      64.     return x;
              ^
      65. }
      66. #endif

libavutil/bswap.h:65:1: return from a call to bswap_32
      63.     x= (x>>16) | (x<<16);
      64.     return x;
      65. }
          ^
      66. #endif
      67. 

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/aac_parser.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/aac_parser.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:417:1: start of procedure skip_bits1()
    415. }
    416. 
    417. static inline void skip_bits1(GetBitContext *s){
         ^
    418.     skip_bits(s, 1);
    419. }

libavcodec/get_bits.h:418:5: 
    416. 
    417. static inline void skip_bits1(GetBitContext *s){
    418.     skip_bits(s, 1);
             ^
    419. }
    420. 

libavcodec/get_bits.h:385:1: start of procedure skip_bits()
      383. }
      384. 
      385. static inline void skip_bits(GetBitContext *s, int n){
           ^
      386.  //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
      387.     OPEN_READER(re, s)

libavcodec/get_bits.h:387:5: 
      385. static inline void skip_bits(GetBitContext *s, int n){
      386.  //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
      387.     OPEN_READER(re, s)
               ^
      388.     UPDATE_CACHE(re, s)
      389.     LAST_SKIP_BITS(re, s, n)

libavcodec/get_bits.h:388:5: 
      386.  //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
      387.     OPEN_READER(re, s)
      388.     UPDATE_CACHE(re, s)
               ^
      389.     LAST_SKIP_BITS(re, s, n)
      390.     CLOSE_READER(re, s)

libavutil/bswap.h:60:1: start of procedure bswap_32()
        58. 
        59. #ifndef bswap_32
        60. static av_always_inline av_const uint32_t bswap_32(uint32_t x)
            ^
        61. {
        62.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);

libavutil/bswap.h:62:5: 
        60. static av_always_inline av_const uint32_t bswap_32(uint32_t x)
        61. {
        62.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
                ^
        63.     x= (x>>16) | (x<<16);
        64.     return x;

libavutil/bswap.h:63:5: 
        61. {
        62.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
        63.     x= (x>>16) | (x<<16);
                ^
        64.     return x;
        65. }

libavutil/bswap.h:64:5: 
        62.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
        63.     x= (x>>16) | (x<<16);
        64.     return x;
                ^
        65. }
        66. #endif

libavutil/bswap.h:65:1: return from a call to bswap_32
        63.     x= (x>>16) | (x<<16);
        64.     return x;
        65. }
            ^
        66. #endif
        67. 

libavcodec/get_bits.h:389:5: 
      387.     OPEN_READER(re, s)
      388.     UPDATE_CACHE(re, s)
      389.     LAST_SKIP_BITS(re, s, n)
               ^
      390.     CLOSE_READER(re, s)
      391. }

libavcodec/get_bits.h:390:5: 
      388.     UPDATE_CACHE(re, s)
      389.     LAST_SKIP_BITS(re, s, n)
      390.     CLOSE_READER(re, s)
               ^
      391. }
      392. 

libavcodec/get_bits.h:391:1: return from a call to skip_bits
      389.     LAST_SKIP_BITS(re, s, n)
      390.     CLOSE_READER(re, s)
      391. }
           ^
      392. 
      393. static inline unsigned int get_bits1(GetBitContext *s){

libavcodec/get_bits.h:419:1: return from a call to skip_bits1
    417. static inline void skip_bits1(GetBitContext *s){
    418.     skip_bits(s, 1);
    419. }
         ^
    420. 
    421. /**

libavcodec/aac_parser.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:385:1: start of procedure skip_bits()
    383. }
    384. 
    385. static inline void skip_bits(GetBitContext *s, int n){
         ^
    386.  //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
    387.     OPEN_READER(re, s)

libavcodec/get_bits.h:387:5: 
    385. static inline void skip_bits(GetBitContext *s, int n){
    386.  //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
    387.     OPEN_READER(re, s)
             ^
    388.     UPDATE_CACHE(re, s)
    389.     LAST_SKIP_BITS(re, s, n)

libavcodec/get_bits.h:388:5: 
    386.  //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
    387.     OPEN_READER(re, s)
    388.     UPDATE_CACHE(re, s)
             ^
    389.     LAST_SKIP_BITS(re, s, n)
    390.     CLOSE_READER(re, s)

libavutil/bswap.h:60:1: start of procedure bswap_32()
      58. 
      59. #ifndef bswap_32
      60. static av_always_inline av_const uint32_t bswap_32(uint32_t x)
          ^
      61. {
      62.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);

libavutil/bswap.h:62:5: 
      60. static av_always_inline av_const uint32_t bswap_32(uint32_t x)
      61. {
      62.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
              ^
      63.     x= (x>>16) | (x<<16);
      64.     return x;

libavutil/bswap.h:63:5: 
      61. {
      62.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
      63.     x= (x>>16) | (x<<16);
              ^
      64.     return x;
      65. }

libavutil/bswap.h:64:5: 
      62.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
      63.     x= (x>>16) | (x<<16);
      64.     return x;
              ^
      65. }
      66. #endif

libavutil/bswap.h:65:1: return from a call to bswap_32
      63.     x= (x>>16) | (x<<16);
      64.     return x;
      65. }
          ^
      66. #endif
      67. 

libavcodec/get_bits.h:389:5: 
    387.     OPEN_READER(re, s)
    388.     UPDATE_CACHE(re, s)
    389.     LAST_SKIP_BITS(re, s, n)
             ^
    390.     CLOSE_READER(re, s)
    391. }

libavcodec/get_bits.h:390:5: 
    388.     UPDATE_CACHE(re, s)
    389.     LAST_SKIP_BITS(re, s, n)
    390.     CLOSE_READER(re, s)
             ^
    391. }
    392. 

libavcodec/get_bits.h:391:1: return from a call to skip_bits
    389.     LAST_SKIP_BITS(re, s, n)
    390.     CLOSE_READER(re, s)
    391. }
         ^
    392. 
    393. static inline unsigned int get_bits1(GetBitContext *s){

libavcodec/aac_parser.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: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 spdif_header_aac(AVFormatContext *s, AVPacket *pkt)
{
    IEC958Context *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 -1;
    }
    ctx->pkt_offset = hdr.samples << 2;
    switch (hdr.num_aac_frames) {
    case 1:
        ctx->data_type = IEC958_MPEG2_AAC;
        break;
    case 2:
        ctx->data_type = IEC958_MPEG2_AAC_LSF_2048;
        break;
    case 4:
        ctx->data_type = IEC958_MPEG2_AAC_LSF_4096;
        break;
    default:
        av_log(s, AV_LOG_ERROR, "%i samples in AAC frame not supported\n",
               hdr.samples);
        return -1;
    }
    return 0;
}
['static int spdif_header_aac(AVFormatContext *s, AVPacket *pkt)\n{\n    IEC958Context *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 -1;\n    }\n    ctx->pkt_offset = hdr.samples << 2;\n    switch (hdr.num_aac_frames) {\n    case 1:\n        ctx->data_type = IEC958_MPEG2_AAC;\n        break;\n    case 2:\n        ctx->data_type = IEC958_MPEG2_AAC_LSF_2048;\n        break;\n    case 4:\n        ctx->data_type = IEC958_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 -1;\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}', '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 bswap_32(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&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}']