libavcodec/wmaenc.c:60: error: Null Dereference
  pointer `extradata` last assigned on line 58 could be null and is dereferenced at line 60, column 9.

libavcodec/wmaenc.c:29:1: start of procedure encode_init()
27. 
28. 
29. static int encode_init(AVCodecContext * avctx){
    ^
30.     WMACodecContext *s = avctx->priv_data;
31.     int i, flags1, flags2;

libavcodec/wmaenc.c:30:5: 
28. 
29. static int encode_init(AVCodecContext * avctx){
30.     WMACodecContext *s = avctx->priv_data;
        ^
31.     int i, flags1, flags2;
32.     uint8_t *extradata;

libavcodec/wmaenc.c:34:5: 
32.     uint8_t *extradata;
33. 
34.     s->avctx = avctx;
        ^
35. 
36.     if(avctx->channels > MAX_CHANNELS) {

libavcodec/wmaenc.c:36:8: Taking false branch
34.     s->avctx = avctx;
35. 
36.     if(avctx->channels > MAX_CHANNELS) {
           ^
37.         av_log(avctx, AV_LOG_ERROR, "too many channels: got %i, need %i or fewer",
38.                avctx->channels, MAX_CHANNELS);

libavcodec/wmaenc.c:42:9: Taking false branch
40.     }
41. 
42.     if (avctx->sample_rate > 48000) {
            ^
43.         av_log(avctx, AV_LOG_ERROR, "sample rate is too high: %d > 48kHz",
44.                avctx->sample_rate);

libavcodec/wmaenc.c:48:8: Taking false branch
46.     }
47. 
48.     if(avctx->bit_rate < 24*1000) {
           ^
49.         av_log(avctx, AV_LOG_ERROR, "bitrate too low: got %i, need 24000 or higher\n",
50.                avctx->bit_rate);

libavcodec/wmaenc.c:55:5: 
53. 
54.     /* extract flag infos */
55.     flags1 = 0;
        ^
56.     flags2 = 1;
57.     if (avctx->codec->id == CODEC_ID_WMAV1) {

libavcodec/wmaenc.c:56:5: 
54.     /* extract flag infos */
55.     flags1 = 0;
56.     flags2 = 1;
        ^
57.     if (avctx->codec->id == CODEC_ID_WMAV1) {
58.         extradata= av_malloc(4);

libavcodec/wmaenc.c:57:9: Taking true branch
55.     flags1 = 0;
56.     flags2 = 1;
57.     if (avctx->codec->id == CODEC_ID_WMAV1) {
            ^
58.         extradata= av_malloc(4);
59.         avctx->extradata_size= 4;

libavcodec/wmaenc.c:58:9: 
56.     flags2 = 1;
57.     if (avctx->codec->id == CODEC_ID_WMAV1) {
58.         extradata= av_malloc(4);
            ^
59.         avctx->extradata_size= 4;
60.         AV_WL16(extradata, flags1);

libavutil/mem.c:64:1: start of procedure av_malloc()
  62.    linker will do it automatically. */
  63. 
  64. void *av_malloc(size_t size)
      ^
  65. {
  66.     void *ptr = NULL;

libavutil/mem.c:66:5: 
  64. void *av_malloc(size_t size)
  65. {
  66.     void *ptr = NULL;
          ^
  67. #if CONFIG_MEMALIGN_HACK
  68.     long diff;

libavutil/mem.c:72:8: Taking false branch
  70. 
  71.     /* let's disallow possible ambiguous cases */
  72.     if(size > (INT_MAX-32) )
             ^
  73.         return NULL;
  74. 

libavutil/mem.c:83:9: Taking true branch
  81.     ((char*)ptr)[-1]= diff;
  82. #elif HAVE_POSIX_MEMALIGN
  83.     if (posix_memalign(&ptr,32,size))
              ^
  84.         ptr = NULL;
  85. #elif HAVE_MEMALIGN

libavutil/mem.c:84:9: 
  82. #elif HAVE_POSIX_MEMALIGN
  83.     if (posix_memalign(&ptr,32,size))
  84.         ptr = NULL;
              ^
  85. #elif HAVE_MEMALIGN
  86.     ptr = memalign(32,size);

libavutil/mem.c:114:5: 
  112.     ptr = malloc(size);
  113. #endif
  114.     return ptr;
           ^
  115. }
  116. 

libavutil/mem.c:115:1: return from a call to av_malloc
  113. #endif
  114.     return ptr;
  115. }
       ^
  116. 
  117. void *av_realloc(void *ptr, size_t size)

libavcodec/wmaenc.c:59:9: 
57.     if (avctx->codec->id == CODEC_ID_WMAV1) {
58.         extradata= av_malloc(4);
59.         avctx->extradata_size= 4;
            ^
60.         AV_WL16(extradata, flags1);
61.         AV_WL16(extradata+2, flags2);

libavcodec/wmaenc.c:60:9: 
58.         extradata= av_malloc(4);
59.         avctx->extradata_size= 4;
60.         AV_WL16(extradata, flags1);
            ^
61.         AV_WL16(extradata+2, flags2);
62.     } else if (avctx->codec->id == CODEC_ID_WMAV2) {

static int encode_init(AVCodecContext * avctx){
    WMACodecContext *s = avctx->priv_data;
    int i, flags1, flags2;
    uint8_t *extradata;
    s->avctx = avctx;
    if(avctx->channels > MAX_CHANNELS) {
        av_log(avctx, AV_LOG_ERROR, "too many channels: got %i, need %i or fewer",
               avctx->channels, MAX_CHANNELS);
        return AVERROR(EINVAL);
    }
    if (avctx->sample_rate > 48000) {
        av_log(avctx, AV_LOG_ERROR, "sample rate is too high: %d > 48kHz",
               avctx->sample_rate);
        return AVERROR(EINVAL);
    }
    if(avctx->bit_rate < 24*1000) {
        av_log(avctx, AV_LOG_ERROR, "bitrate too low: got %i, need 24000 or higher\n",
               avctx->bit_rate);
        return AVERROR(EINVAL);
    }
    flags1 = 0;
    flags2 = 1;
    if (avctx->codec->id == CODEC_ID_WMAV1) {
        extradata= av_malloc(4);
        avctx->extradata_size= 4;
        AV_WL16(extradata, flags1);
        AV_WL16(extradata+2, flags2);
    } else if (avctx->codec->id == CODEC_ID_WMAV2) {
        extradata= av_mallocz(10);
        avctx->extradata_size= 10;
        AV_WL32(extradata, flags1);
        AV_WL16(extradata+4, flags2);
    }else
        assert(0);
    avctx->extradata= extradata;
    s->use_exp_vlc = flags2 & 0x0001;
    s->use_bit_reservoir = flags2 & 0x0002;
    s->use_variable_block_len = flags2 & 0x0004;
    ff_wma_init(avctx, flags2);
    for(i = 0; i < s->nb_block_sizes; i++)
        ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 0, 1.0);
    s->block_align     = avctx->bit_rate * (int64_t)s->frame_len /
                         (avctx->sample_rate * 8);
    s->block_align     = FFMIN(s->block_align, MAX_CODED_SUPERFRAME_SIZE);
    avctx->block_align = s->block_align;
    avctx->bit_rate    = avctx->block_align * 8LL * avctx->sample_rate /
                         s->frame_len;
    avctx->frame_size= s->frame_len;
    return 0;
}
['static int encode_init(AVCodecContext * avctx){\n    WMACodecContext *s = avctx->priv_data;\n    int i, flags1, flags2;\n    uint8_t *extradata;\n    s->avctx = avctx;\n    if(avctx->channels > MAX_CHANNELS) {\n        av_log(avctx, AV_LOG_ERROR, "too many channels: got %i, need %i or fewer",\n               avctx->channels, MAX_CHANNELS);\n        return AVERROR(EINVAL);\n    }\n    if (avctx->sample_rate > 48000) {\n        av_log(avctx, AV_LOG_ERROR, "sample rate is too high: %d > 48kHz",\n               avctx->sample_rate);\n        return AVERROR(EINVAL);\n    }\n    if(avctx->bit_rate < 24*1000) {\n        av_log(avctx, AV_LOG_ERROR, "bitrate too low: got %i, need 24000 or higher\\n",\n               avctx->bit_rate);\n        return AVERROR(EINVAL);\n    }\n    flags1 = 0;\n    flags2 = 1;\n    if (avctx->codec->id == CODEC_ID_WMAV1) {\n        extradata= av_malloc(4);\n        avctx->extradata_size= 4;\n        AV_WL16(extradata, flags1);\n        AV_WL16(extradata+2, flags2);\n    } else if (avctx->codec->id == CODEC_ID_WMAV2) {\n        extradata= av_mallocz(10);\n        avctx->extradata_size= 10;\n        AV_WL32(extradata, flags1);\n        AV_WL16(extradata+4, flags2);\n    }else\n        assert(0);\n    avctx->extradata= extradata;\n    s->use_exp_vlc = flags2 & 0x0001;\n    s->use_bit_reservoir = flags2 & 0x0002;\n    s->use_variable_block_len = flags2 & 0x0004;\n    ff_wma_init(avctx, flags2);\n    for(i = 0; i < s->nb_block_sizes; i++)\n        ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 0, 1.0);\n    s->block_align     = avctx->bit_rate * (int64_t)s->frame_len /\n                         (avctx->sample_rate * 8);\n    s->block_align     = FFMIN(s->block_align, MAX_CODED_SUPERFRAME_SIZE);\n    avctx->block_align = s->block_align;\n    avctx->bit_rate    = avctx->block_align * 8LL * avctx->sample_rate /\n                         s->frame_len;\n    avctx->frame_size= s->frame_len;\n    return 0;\n}', 'void *av_malloc(size_t size)\n{\n    void *ptr = NULL;\n#if CONFIG_MEMALIGN_HACK\n    long diff;\n#endif\n    if(size > (INT_MAX-32) )\n        return NULL;\n#if CONFIG_MEMALIGN_HACK\n    ptr = malloc(size+32);\n    if(!ptr)\n        return ptr;\n    diff= ((-(long)ptr - 1)&31) + 1;\n    ptr = (char*)ptr + diff;\n    ((char*)ptr)[-1]= diff;\n#elif HAVE_POSIX_MEMALIGN\n    if (posix_memalign(&ptr,32,size))\n        ptr = NULL;\n#elif HAVE_MEMALIGN\n    ptr = memalign(32,size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}']