libavcodec/alacenc.c:470: error: Null Dereference
  pointer `s->pbctx.buf_ptr` last assigned on line 465 could be null and is dereferenced by call to `write_frame_header()` at line 470, column 9.

libavcodec/alacenc.c:447:1: start of procedure alac_encode_frame()
445. }
446. 
447. static int alac_encode_frame(AVCodecContext *avctx, uint8_t *frame,
     ^
448.                              int buf_size, void *data)
449. {

libavcodec/alacenc.c:450:5: 
448.                              int buf_size, void *data)
449. {
450.     AlacEncodeContext *s = avctx->priv_data;
         ^
451.     PutBitContext *pb = &s->pbctx;
452.     int i, out_bytes, verbatim_flag = 0;

libavcodec/alacenc.c:451:5: 
449. {
450.     AlacEncodeContext *s = avctx->priv_data;
451.     PutBitContext *pb = &s->pbctx;
         ^
452.     int i, out_bytes, verbatim_flag = 0;
453. 

libavcodec/alacenc.c:452:5: 
450.     AlacEncodeContext *s = avctx->priv_data;
451.     PutBitContext *pb = &s->pbctx;
452.     int i, out_bytes, verbatim_flag = 0;
         ^
453. 
454.     if(avctx->frame_size > DEFAULT_FRAME_SIZE) {

libavcodec/alacenc.c:454:8: Taking false branch
452.     int i, out_bytes, verbatim_flag = 0;
453. 
454.     if(avctx->frame_size > DEFAULT_FRAME_SIZE) {
            ^
455.         av_log(avctx, AV_LOG_ERROR, "input frame size exceeded\n");
456.         return -1;

libavcodec/alacenc.c:459:8: Taking false branch
457.     }
458. 
459.     if(buf_size < 2*s->max_coded_frame_size) {
            ^
460.         av_log(avctx, AV_LOG_ERROR, "buffer size is too small\n");
461.         return -1;

libavcodec/alacenc.c:492:9: 
490.         }
491.         verbatim_flag = 1;
492.         goto verbatim;
             ^
493.     }
494. 

libavcodec/alacenc.c:465:5: 
463. 
464. verbatim:
465.     init_put_bits(pb, frame, buf_size);
         ^
466. 
467.     if((s->compression_level == 0) || verbatim_flag) {

libavcodec/bitstream.h:90:1: start of procedure init_put_bits()
  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:92:8: Taking true branch
  90. static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
  91. {
  92.     if(buffer_size < 0) {
             ^
  93.         buffer_size = 0;
  94.         buffer = NULL;

libavcodec/bitstream.h:93:9: 
  91. {
  92.     if(buffer_size < 0) {
  93.         buffer_size = 0;
              ^
  94.         buffer = NULL;
  95.     }

libavcodec/bitstream.h:94:9: 
  92.     if(buffer_size < 0) {
  93.         buffer_size = 0;
  94.         buffer = NULL;
              ^
  95.     }
  96. 

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

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

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

libavcodec/bitstream.h:105:5: 
  103. #else
  104.     s->buf_ptr = s->buf;
  105.     s->bit_left=32;
           ^
  106.     s->bit_buf=0;
  107. #endif

libavcodec/bitstream.h:106:5: 
  104.     s->buf_ptr = s->buf;
  105.     s->bit_left=32;
  106.     s->bit_buf=0;
           ^
  107. #endif
  108. }

libavcodec/bitstream.h:108:1: return from a call to init_put_bits
  106.     s->bit_buf=0;
  107. #endif
  108. }
       ^
  109. 
  110. /* return the number of bits output */

libavcodec/alacenc.c:467:9: Taking true branch
465.     init_put_bits(pb, frame, buf_size);
466. 
467.     if((s->compression_level == 0) || verbatim_flag) {
             ^
468.         // Verbatim mode
469.         int16_t *samples = data;

libavcodec/alacenc.c:469:9: 
467.     if((s->compression_level == 0) || verbatim_flag) {
468.         // Verbatim mode
469.         int16_t *samples = data;
             ^
470.         write_frame_header(s, 1);
471.         for(i=0; i<avctx->frame_size*avctx->channels; i++) {

libavcodec/alacenc.c:470:9: 
468.         // Verbatim mode
469.         int16_t *samples = data;
470.         write_frame_header(s, 1);
             ^
471.         for(i=0; i<avctx->frame_size*avctx->channels; i++) {
472.             put_sbits(pb, 16, *samples++);

libavcodec/alacenc.c:117:1: start of procedure write_frame_header()
  115. }
  116. 
  117. static void write_frame_header(AlacEncodeContext *s, int is_verbatim)
       ^
  118. {
  119.     put_bits(&s->pbctx, 3,  s->avctx->channels-1);          // No. of channels -1

libavcodec/alacenc.c:119:5: 
  117. static void write_frame_header(AlacEncodeContext *s, int is_verbatim)
  118. {
  119.     put_bits(&s->pbctx, 3,  s->avctx->channels-1);          // No. of channels -1
           ^
  120.     put_bits(&s->pbctx, 16, 0);                             // Seems to be zero
  121.     put_bits(&s->pbctx, 1,  1);                             // Sample count is in the header

libavcodec/bitstream.h:187:1: start of procedure put_bits()
    185. 
    186. #ifndef ALT_BITSTREAM_WRITER
    187. static inline void put_bits(PutBitContext *s, int n, unsigned int value)
         ^
    188. {
    189.     unsigned int bit_buf;

libavcodec/bitstream.h:193:5: 
    191. 
    192.     //    printf("put_bits=%d %x\n", n, value);
    193.     assert(n == 32 || value < (1U << n));
             ^
    194. 
    195.     bit_buf = s->bit_buf;

libavcodec/bitstream.h:195:5: 
    193.     assert(n == 32 || value < (1U << n));
    194. 
    195.     bit_buf = s->bit_buf;
             ^
    196.     bit_left = s->bit_left;
    197. 

libavcodec/bitstream.h:196:5: 
    194. 
    195.     bit_buf = s->bit_buf;
    196.     bit_left = s->bit_left;
             ^
    197. 
    198.     //    printf("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt, bit_buf);

libavcodec/bitstream.h:218:9: Taking false branch
    216.     bit_left-=n;
    217. #else
    218.     if (n < bit_left) {
                 ^
    219.         bit_buf = (bit_buf<<n) | value;
    220.         bit_left-=n;

libavcodec/bitstream.h:222:9: 
    220.         bit_left-=n;
    221.     } else {
    222.         bit_buf<<=bit_left;
                 ^
    223.         bit_buf |= value >> (n - bit_left);
    224. #ifdef UNALIGNED_STORES_ARE_BAD

libavcodec/bitstream.h:223:9: 
    221.     } else {
    222.         bit_buf<<=bit_left;
    223.         bit_buf |= value >> (n - bit_left);
                 ^
    224. #ifdef UNALIGNED_STORES_ARE_BAD
    225.         if (3 & (intptr_t) s->buf_ptr) {

libavcodec/bitstream.h:232:9: 
    230.         } else
    231. #endif
    232.         *(uint32_t *)s->buf_ptr = be2me_32(bit_buf);
                 ^
    233.         //printf("bitbuf = %08x\n", bit_buf);
    234.         s->buf_ptr+=4;

static int alac_encode_frame(AVCodecContext *avctx, uint8_t *frame,
                             int buf_size, void *data)
{
    AlacEncodeContext *s = avctx->priv_data;
    PutBitContext *pb = &s->pbctx;
    int i, out_bytes, verbatim_flag = 0;
    if(avctx->frame_size > DEFAULT_FRAME_SIZE) {
        av_log(avctx, AV_LOG_ERROR, "input frame size exceeded\n");
        return -1;
    }
    if(buf_size < 2*s->max_coded_frame_size) {
        av_log(avctx, AV_LOG_ERROR, "buffer size is too small\n");
        return -1;
    }
verbatim:
    init_put_bits(pb, frame, buf_size);
    if((s->compression_level == 0) || verbatim_flag) {
        int16_t *samples = data;
        write_frame_header(s, 1);
        for(i=0; i<avctx->frame_size*avctx->channels; i++) {
            put_sbits(pb, 16, *samples++);
        }
    } else {
        init_sample_buffers(s, data);
        write_frame_header(s, 0);
        write_compressed_frame(s);
    }
    put_bits(pb, 3, 7);
    flush_put_bits(pb);
    out_bytes = put_bits_count(pb) >> 3;
    if(out_bytes > s->max_coded_frame_size) {
        if(verbatim_flag || (s->compression_level == 0)) {
            av_log(avctx, AV_LOG_ERROR, "error encoding frame\n");
            return -1;
        }
        verbatim_flag = 1;
        goto verbatim;
    }
    return out_bytes;
}
['static int alac_encode_frame(AVCodecContext *avctx, uint8_t *frame,\n                             int buf_size, void *data)\n{\n    AlacEncodeContext *s = avctx->priv_data;\n    PutBitContext *pb = &s->pbctx;\n    int i, out_bytes, verbatim_flag = 0;\n    if(avctx->frame_size > DEFAULT_FRAME_SIZE) {\n        av_log(avctx, AV_LOG_ERROR, "input frame size exceeded\\n");\n        return -1;\n    }\n    if(buf_size < 2*s->max_coded_frame_size) {\n        av_log(avctx, AV_LOG_ERROR, "buffer size is too small\\n");\n        return -1;\n    }\nverbatim:\n    init_put_bits(pb, frame, buf_size);\n    if((s->compression_level == 0) || verbatim_flag) {\n        int16_t *samples = data;\n        write_frame_header(s, 1);\n        for(i=0; i<avctx->frame_size*avctx->channels; i++) {\n            put_sbits(pb, 16, *samples++);\n        }\n    } else {\n        init_sample_buffers(s, data);\n        write_frame_header(s, 0);\n        write_compressed_frame(s);\n    }\n    put_bits(pb, 3, 7);\n    flush_put_bits(pb);\n    out_bytes = put_bits_count(pb) >> 3;\n    if(out_bytes > s->max_coded_frame_size) {\n        if(verbatim_flag || (s->compression_level == 0)) {\n            av_log(avctx, AV_LOG_ERROR, "error encoding frame\\n");\n            return -1;\n        }\n        verbatim_flag = 1;\n        goto verbatim;\n    }\n    return out_bytes;\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 void write_frame_header(AlacEncodeContext *s, int is_verbatim)\n{\n    put_bits(&s->pbctx, 3,  s->avctx->channels-1);\n    put_bits(&s->pbctx, 16, 0);\n    put_bits(&s->pbctx, 1,  1);\n    put_bits(&s->pbctx, 2,  0);\n    put_bits(&s->pbctx, 1,  is_verbatim);\n    put_bits(&s->pbctx, 32, s->avctx->frame_size);\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#ifdef UNALIGNED_STORES_ARE_BAD\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#ifdef UNALIGNED_STORES_ARE_BAD\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}']