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

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

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

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

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

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

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

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

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

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

libavcodec/wmaenc.c:59:9: 
57.     flags2 = 1;
58.     if (avctx->codec->id == CODEC_ID_WMAV1) {
59.         extradata= av_malloc(4);
            ^
60.         avctx->extradata_size= 4;
61.         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:9: Taking false branch
  70. 
  71.     /* let's disallow possible ambiguous cases */
  72.     if (size > (INT_MAX-32) || !size)
              ^
  73.         return NULL;
  74. 

libavutil/mem.c:72:33: Taking false branch
  70. 
  71.     /* let's disallow possible ambiguous cases */
  72.     if (size > (INT_MAX-32) || !size)
                                      ^
  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_ALIGNED_MALLOC

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

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, size_t size)

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

libavcodec/wmaenc.c:61:9: 
59.         extradata= av_malloc(4);
60.         avctx->extradata_size= 4;
61.         AV_WL16(extradata, flags1);
            ^
62.         AV_WL16(extradata+2, flags2);
63.     } 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;
    if (avctx->channels == 2)
        s->ms_stereo = 1;
    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 = avctx->delay = s->frame_len;
#if FF_API_OLD_ENCODE_AUDIO
    avctx->coded_frame = &s->frame;
    avcodec_get_frame_defaults(avctx->coded_frame);
#endif
    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    if (avctx->channels == 2)\n        s->ms_stereo = 1;\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 = avctx->delay = s->frame_len;\n#if FF_API_OLD_ENCODE_AUDIO\n    avctx->coded_frame = &s->frame;\n    avcodec_get_frame_defaults(avctx->coded_frame);\n#endif\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) || !size)\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_ALIGNED_MALLOC\n    ptr = _aligned_malloc(size, 32);\n#elif HAVE_MEMALIGN\n    ptr = memalign(32,size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}']