Revision 0edf8a7a

View differences:

libavcodec/utils.c
71 71

  
72 72
    avctx->codec = codec;
73 73
    avctx->frame_number = 0;
74
    avctx->priv_data = av_mallocz(codec->priv_data_size);
75
    if (!avctx->priv_data) 
76
        return -ENOMEM;
74
    if (codec->priv_data_size > 0) {
75
        avctx->priv_data = av_mallocz(codec->priv_data_size);
76
        if (!avctx->priv_data) 
77
            return -ENOMEM;
78
    } else {
79
        avctx->priv_data = NULL;
80
    }
77 81
    ret = avctx->codec->init(avctx);
78 82
    if (ret < 0) {
79
        free(avctx->priv_data);
83
        if (avctx->priv_data)
84
            free(avctx->priv_data);
80 85
        avctx->priv_data = NULL;
81 86
        return ret;
82 87
    }

Also available in: Unified diff