libavcodec/wmaenc.c:48: error: Null Dereference
  pointer `extradata` last assigned on line 46 could be null and is dereferenced at line 48, 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.         return -1;
38. 

libavcodec/wmaenc.c:39:8: Taking false branch
37.         return -1;
38. 
39.     if(avctx->bit_rate < 24*1000)
           ^
40.         return -1;
41. 

libavcodec/wmaenc.c:43:5: 
41. 
42.     /* extract flag infos */
43.     flags1 = 0;
        ^
44.     flags2 = 1;
45.     if (avctx->codec->id == CODEC_ID_WMAV1) {

libavcodec/wmaenc.c:44:5: 
42.     /* extract flag infos */
43.     flags1 = 0;
44.     flags2 = 1;
        ^
45.     if (avctx->codec->id == CODEC_ID_WMAV1) {
46.         extradata= av_malloc(4);

libavcodec/wmaenc.c:45:9: Taking true branch
43.     flags1 = 0;
44.     flags2 = 1;
45.     if (avctx->codec->id == CODEC_ID_WMAV1) {
            ^
46.         extradata= av_malloc(4);
47.         avctx->extradata_size= 4;

libavcodec/wmaenc.c:46:9: 
44.     flags2 = 1;
45.     if (avctx->codec->id == CODEC_ID_WMAV1) {
46.         extradata= av_malloc(4);
            ^
47.         avctx->extradata_size= 4;
48.         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(FF_INTERNAL_MEM_TYPE size)
      ^
  65. {
  66.     void *ptr = NULL;

libavutil/mem.c:66:5: 
  64. void *av_malloc(FF_INTERNAL_MEM_TYPE 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-16) )
             ^
  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,16,size))
              ^
  84.         ptr = NULL;
  85. #elif HAVE_MEMALIGN

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

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

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

libavcodec/wmaenc.c:47:9: 
45.     if (avctx->codec->id == CODEC_ID_WMAV1) {
46.         extradata= av_malloc(4);
47.         avctx->extradata_size= 4;
            ^
48.         AV_WL16(extradata, flags1);
49.         AV_WL16(extradata+2, flags2);

libavcodec/wmaenc.c:48:9: 
46.         extradata= av_malloc(4);
47.         avctx->extradata_size= 4;
48.         AV_WL16(extradata, flags1);
            ^
49.         AV_WL16(extradata+2, flags2);
50.     } 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)
        return -1;
    if(avctx->bit_rate < 24*1000)
        return -1;
    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);
    avctx->block_align=
    s->block_align= avctx->bit_rate*(int64_t)s->frame_len / (avctx->sample_rate*8);
    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        return -1;\n    if(avctx->bit_rate < 24*1000)\n        return -1;\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    avctx->block_align=\n    s->block_align= avctx->bit_rate*(int64_t)s->frame_len / (avctx->sample_rate*8);\n    avctx->frame_size= s->frame_len;\n    return 0;\n}', 'void *av_malloc(FF_INTERNAL_MEM_TYPE size)\n{\n    void *ptr = NULL;\n#if CONFIG_MEMALIGN_HACK\n    long diff;\n#endif\n    if(size > (INT_MAX-16) )\n        return NULL;\n#if 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 HAVE_POSIX_MEMALIGN\n    if (posix_memalign(&ptr,16,size))\n        ptr = NULL;\n#elif HAVE_MEMALIGN\n    ptr = memalign(16,size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}']