libavcodec/alacenc.c:392: error: Null Dereference
  pointer `alac_extradata` last assigned on line 365 could be null and is dereferenced at line 392, column 5.

libavcodec/alacenc.c:362:1: start of procedure alac_encode_init()
360. }
361. 
362. static av_cold int alac_encode_init(AVCodecContext *avctx)
     ^
363. {
364.     AlacEncodeContext *s    = avctx->priv_data;

libavcodec/alacenc.c:364:5: 
362. static av_cold int alac_encode_init(AVCodecContext *avctx)
363. {
364.     AlacEncodeContext *s    = avctx->priv_data;
         ^
365.     uint8_t *alac_extradata = av_mallocz(ALAC_EXTRADATA_SIZE+1);
366. 

libavcodec/alacenc.c:365:5: 
363. {
364.     AlacEncodeContext *s    = avctx->priv_data;
365.     uint8_t *alac_extradata = av_mallocz(ALAC_EXTRADATA_SIZE+1);
         ^
366. 
367.     avctx->frame_size      = DEFAULT_FRAME_SIZE;

libavutil/mem.c:132:1: start of procedure av_mallocz()
  130. }
  131. 
  132. void *av_mallocz(unsigned int size)
       ^
  133. {
  134.     void *ptr = av_malloc(size);

libavutil/mem.c:134:5: 
  132. void *av_mallocz(unsigned int size)
  133. {
  134.     void *ptr = av_malloc(size);
           ^
  135.     if (ptr)
  136.         memset(ptr, 0, size);

libavutil/mem.c:42:1: start of procedure av_malloc()
    40.    linker will do it automatically */
    41. 
    42. void *av_malloc(unsigned int size)
        ^
    43. {
    44.     void *ptr;

libavutil/mem.c:50:8: Taking false branch
    48. 
    49.     /* let's disallow possible ambiguous cases */
    50.     if(size > (INT_MAX-16) )
               ^
    51.         return NULL;
    52. 

libavutil/mem.c:61:5: Skipping memalign(): method has no implementation
    59.     ((char*)ptr)[-1]= diff;
    60. #elif defined (HAVE_MEMALIGN)
    61.     ptr = memalign(16,size);
            ^
    62.     /* Why 64?
    63.        Indeed, we should align it:

libavutil/mem.c:91:5: 
    89.     ptr = malloc(size);
    90. #endif
    91.     return ptr;
            ^
    92. }
    93. 

libavutil/mem.c:92:1: return from a call to av_malloc
    90. #endif
    91.     return ptr;
    92. }
        ^
    93. 
    94. void *av_realloc(void *ptr, unsigned int size)

libavutil/mem.c:135:9: Taking false branch
  133. {
  134.     void *ptr = av_malloc(size);
  135.     if (ptr)
               ^
  136.         memset(ptr, 0, size);
  137.     return ptr;

libavutil/mem.c:137:5: 
  135.     if (ptr)
  136.         memset(ptr, 0, size);
  137.     return ptr;
           ^
  138. }
  139. 

libavutil/mem.c:138:1: return from a call to av_mallocz
  136.         memset(ptr, 0, size);
  137.     return ptr;
  138. }
       ^
  139. 
  140. char *av_strdup(const char *s)

libavcodec/alacenc.c:367:5: 
365.     uint8_t *alac_extradata = av_mallocz(ALAC_EXTRADATA_SIZE+1);
366. 
367.     avctx->frame_size      = DEFAULT_FRAME_SIZE;
         ^
368.     avctx->bits_per_coded_sample = DEFAULT_SAMPLE_SIZE;
369. 

libavcodec/alacenc.c:368:5: 
366. 
367.     avctx->frame_size      = DEFAULT_FRAME_SIZE;
368.     avctx->bits_per_coded_sample = DEFAULT_SAMPLE_SIZE;
         ^
369. 
370.     if(avctx->sample_fmt != SAMPLE_FMT_S16) {

libavcodec/alacenc.c:370:8: Taking false branch
368.     avctx->bits_per_coded_sample = DEFAULT_SAMPLE_SIZE;
369. 
370.     if(avctx->sample_fmt != SAMPLE_FMT_S16) {
            ^
371.         av_log(avctx, AV_LOG_ERROR, "only pcm_s16 input samples are supported\n");
372.         return -1;

libavcodec/alacenc.c:376:8: Taking false branch
374. 
375.     // Set default compression level
376.     if(avctx->compression_level == FF_COMPRESSION_DEFAULT)
            ^
377.         s->compression_level = 1;
378.     else

libavcodec/alacenc.c:379:9: 
377.         s->compression_level = 1;
378.     else
379.         s->compression_level = av_clip(avctx->compression_level, 0, 1);
             ^
380. 
381.     // Initialize default Rice parameters

libavutil/common.h:200:1: start of procedure av_clip()
  198.  * @return clipped value
  199.  */
  200. static inline av_const int av_clip(int a, int amin, int amax)
       ^
  201. {
  202.     if      (a < amin) return amin;

libavutil/common.h:202:14: Taking false branch
  200. static inline av_const int av_clip(int a, int amin, int amax)
  201. {
  202.     if      (a < amin) return amin;
                    ^
  203.     else if (a > amax) return amax;
  204.     else               return a;

libavutil/common.h:203:14: Taking false branch
  201. {
  202.     if      (a < amin) return amin;
  203.     else if (a > amax) return amax;
                    ^
  204.     else               return a;
  205. }

libavutil/common.h:204:24: 
  202.     if      (a < amin) return amin;
  203.     else if (a > amax) return amax;
  204.     else               return a;
                              ^
  205. }
  206. 

libavutil/common.h:205:1: return from a call to av_clip
  203.     else if (a > amax) return amax;
  204.     else               return a;
  205. }
       ^
  206. 
  207. /**

libavcodec/alacenc.c:382:5: 
380. 
381.     // Initialize default Rice parameters
382.     s->rc.history_mult    = 40;
         ^
383.     s->rc.initial_history = 10;
384.     s->rc.k_modifier      = 14;

libavcodec/alacenc.c:383:5: 
381.     // Initialize default Rice parameters
382.     s->rc.history_mult    = 40;
383.     s->rc.initial_history = 10;
         ^
384.     s->rc.k_modifier      = 14;
385.     s->rc.rice_modifier   = 4;

libavcodec/alacenc.c:384:5: 
382.     s->rc.history_mult    = 40;
383.     s->rc.initial_history = 10;
384.     s->rc.k_modifier      = 14;
         ^
385.     s->rc.rice_modifier   = 4;
386. 

libavcodec/alacenc.c:385:5: 
383.     s->rc.initial_history = 10;
384.     s->rc.k_modifier      = 14;
385.     s->rc.rice_modifier   = 4;
         ^
386. 
387.     s->max_coded_frame_size = (ALAC_FRAME_HEADER_SIZE + ALAC_FRAME_FOOTER_SIZE +

libavcodec/alacenc.c:387:5: 
385.     s->rc.rice_modifier   = 4;
386. 
387.     s->max_coded_frame_size = (ALAC_FRAME_HEADER_SIZE + ALAC_FRAME_FOOTER_SIZE +
         ^
388.                                avctx->frame_size*avctx->channels*avctx->bits_per_coded_sample)>>3;
389. 

libavcodec/alacenc.c:390:5: 
388.                                avctx->frame_size*avctx->channels*avctx->bits_per_coded_sample)>>3;
389. 
390.     s->write_sample_size  = avctx->bits_per_coded_sample + avctx->channels - 1; // FIXME: consider wasted_bytes
         ^
391. 
392.     AV_WB32(alac_extradata,    ALAC_EXTRADATA_SIZE);

libavcodec/alacenc.c:392:5: 
390.     s->write_sample_size  = avctx->bits_per_coded_sample + avctx->channels - 1; // FIXME: consider wasted_bytes
391. 
392.     AV_WB32(alac_extradata,    ALAC_EXTRADATA_SIZE);
         ^
393.     AV_WB32(alac_extradata+4,  MKBETAG('a','l','a','c'));
394.     AV_WB32(alac_extradata+12, avctx->frame_size);

static av_cold int alac_encode_init(AVCodecContext *avctx)
{
    AlacEncodeContext *s    = avctx->priv_data;
    uint8_t *alac_extradata = av_mallocz(ALAC_EXTRADATA_SIZE+1);
    avctx->frame_size      = DEFAULT_FRAME_SIZE;
    avctx->bits_per_coded_sample = DEFAULT_SAMPLE_SIZE;
    if(avctx->sample_fmt != SAMPLE_FMT_S16) {
        av_log(avctx, AV_LOG_ERROR, "only pcm_s16 input samples are supported\n");
        return -1;
    }
    if(avctx->compression_level == FF_COMPRESSION_DEFAULT)
        s->compression_level = 1;
    else
        s->compression_level = av_clip(avctx->compression_level, 0, 1);
    s->rc.history_mult    = 40;
    s->rc.initial_history = 10;
    s->rc.k_modifier      = 14;
    s->rc.rice_modifier   = 4;
    s->max_coded_frame_size = (ALAC_FRAME_HEADER_SIZE + ALAC_FRAME_FOOTER_SIZE +
                               avctx->frame_size*avctx->channels*avctx->bits_per_coded_sample)>>3;
    s->write_sample_size  = avctx->bits_per_coded_sample + avctx->channels - 1;
    AV_WB32(alac_extradata,    ALAC_EXTRADATA_SIZE);
    AV_WB32(alac_extradata+4,  MKBETAG('a','l','a','c'));
    AV_WB32(alac_extradata+12, avctx->frame_size);
    AV_WB8 (alac_extradata+17, avctx->bits_per_coded_sample);
    AV_WB8 (alac_extradata+21, avctx->channels);
    AV_WB32(alac_extradata+24, s->max_coded_frame_size);
    AV_WB32(alac_extradata+28, avctx->sample_rate*avctx->channels*avctx->bits_per_coded_sample);
    AV_WB32(alac_extradata+32, avctx->sample_rate);
    if(s->compression_level > 0) {
        AV_WB8(alac_extradata+18, s->rc.history_mult);
        AV_WB8(alac_extradata+19, s->rc.initial_history);
        AV_WB8(alac_extradata+20, s->rc.k_modifier);
    }
    s->min_prediction_order = DEFAULT_MIN_PRED_ORDER;
    if(avctx->min_prediction_order >= 0) {
        if(avctx->min_prediction_order < MIN_LPC_ORDER ||
           avctx->min_prediction_order > ALAC_MAX_LPC_ORDER) {
            av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n", avctx->min_prediction_order);
                return -1;
        }
        s->min_prediction_order = avctx->min_prediction_order;
    }
    s->max_prediction_order = DEFAULT_MAX_PRED_ORDER;
    if(avctx->max_prediction_order >= 0) {
        if(avctx->max_prediction_order < MIN_LPC_ORDER ||
           avctx->max_prediction_order > ALAC_MAX_LPC_ORDER) {
            av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n", avctx->max_prediction_order);
                return -1;
        }
        s->max_prediction_order = avctx->max_prediction_order;
    }
    if(s->max_prediction_order < s->min_prediction_order) {
        av_log(avctx, AV_LOG_ERROR, "invalid prediction orders: min=%d max=%d\n",
               s->min_prediction_order, s->max_prediction_order);
        return -1;
    }
    avctx->extradata = alac_extradata;
    avctx->extradata_size = ALAC_EXTRADATA_SIZE;
    avctx->coded_frame = avcodec_alloc_frame();
    avctx->coded_frame->key_frame = 1;
    s->avctx = avctx;
    dsputil_init(&s->dspctx, avctx);
    return 0;
}
['static av_cold int alac_encode_init(AVCodecContext *avctx)\n{\n    AlacEncodeContext *s    = avctx->priv_data;\n    uint8_t *alac_extradata = av_mallocz(ALAC_EXTRADATA_SIZE+1);\n    avctx->frame_size      = DEFAULT_FRAME_SIZE;\n    avctx->bits_per_coded_sample = DEFAULT_SAMPLE_SIZE;\n    if(avctx->sample_fmt != SAMPLE_FMT_S16) {\n        av_log(avctx, AV_LOG_ERROR, "only pcm_s16 input samples are supported\\n");\n        return -1;\n    }\n    if(avctx->compression_level == FF_COMPRESSION_DEFAULT)\n        s->compression_level = 1;\n    else\n        s->compression_level = av_clip(avctx->compression_level, 0, 1);\n    s->rc.history_mult    = 40;\n    s->rc.initial_history = 10;\n    s->rc.k_modifier      = 14;\n    s->rc.rice_modifier   = 4;\n    s->max_coded_frame_size = (ALAC_FRAME_HEADER_SIZE + ALAC_FRAME_FOOTER_SIZE +\n                               avctx->frame_size*avctx->channels*avctx->bits_per_coded_sample)>>3;\n    s->write_sample_size  = avctx->bits_per_coded_sample + avctx->channels - 1;\n    AV_WB32(alac_extradata,    ALAC_EXTRADATA_SIZE);\n    AV_WB32(alac_extradata+4,  MKBETAG(\'a\',\'l\',\'a\',\'c\'));\n    AV_WB32(alac_extradata+12, avctx->frame_size);\n    AV_WB8 (alac_extradata+17, avctx->bits_per_coded_sample);\n    AV_WB8 (alac_extradata+21, avctx->channels);\n    AV_WB32(alac_extradata+24, s->max_coded_frame_size);\n    AV_WB32(alac_extradata+28, avctx->sample_rate*avctx->channels*avctx->bits_per_coded_sample);\n    AV_WB32(alac_extradata+32, avctx->sample_rate);\n    if(s->compression_level > 0) {\n        AV_WB8(alac_extradata+18, s->rc.history_mult);\n        AV_WB8(alac_extradata+19, s->rc.initial_history);\n        AV_WB8(alac_extradata+20, s->rc.k_modifier);\n    }\n    s->min_prediction_order = DEFAULT_MIN_PRED_ORDER;\n    if(avctx->min_prediction_order >= 0) {\n        if(avctx->min_prediction_order < MIN_LPC_ORDER ||\n           avctx->min_prediction_order > ALAC_MAX_LPC_ORDER) {\n            av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\\n", avctx->min_prediction_order);\n                return -1;\n        }\n        s->min_prediction_order = avctx->min_prediction_order;\n    }\n    s->max_prediction_order = DEFAULT_MAX_PRED_ORDER;\n    if(avctx->max_prediction_order >= 0) {\n        if(avctx->max_prediction_order < MIN_LPC_ORDER ||\n           avctx->max_prediction_order > ALAC_MAX_LPC_ORDER) {\n            av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\\n", avctx->max_prediction_order);\n                return -1;\n        }\n        s->max_prediction_order = avctx->max_prediction_order;\n    }\n    if(s->max_prediction_order < s->min_prediction_order) {\n        av_log(avctx, AV_LOG_ERROR, "invalid prediction orders: min=%d max=%d\\n",\n               s->min_prediction_order, s->max_prediction_order);\n        return -1;\n    }\n    avctx->extradata = alac_extradata;\n    avctx->extradata_size = ALAC_EXTRADATA_SIZE;\n    avctx->coded_frame = avcodec_alloc_frame();\n    avctx->coded_frame->key_frame = 1;\n    s->avctx = avctx;\n    dsputil_init(&s->dspctx, avctx);\n    return 0;\n}', 'void *av_mallocz(unsigned int size)\n{\n    void *ptr = av_malloc(size);\n    if (ptr)\n        memset(ptr, 0, size);\n    return ptr;\n}', 'void *av_malloc(unsigned int size)\n{\n    void *ptr;\n#ifdef CONFIG_MEMALIGN_HACK\n    long diff;\n#endif\n    if(size > (INT_MAX-16) )\n        return NULL;\n#ifdef CONFIG_MEMALIGN_HACK\n    ptr = malloc(size+16);\n    if(!ptr)\n        return ptr;\n    diff= ((-(long)ptr - 1)&15) + 1;\n    ptr = (char*)ptr + diff;\n    ((char*)ptr)[-1]= diff;\n#elif defined (HAVE_MEMALIGN)\n    ptr = memalign(16,size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}', 'static inline av_const int av_clip(int a, int amin, int amax)\n{\n    if      (a < amin) return amin;\n    else if (a > amax) return amax;\n    else               return a;\n}']