Merge "Handle mem allocation failure in vp8e_init"

This commit is contained in:
Johann 2011-02-25 06:55:10 -08:00 committed by Code Review
commit 1fae7018a8

View File

@ -492,8 +492,11 @@ static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx)
{
priv = calloc(1, sizeof(struct vpx_codec_alg_priv));
if (priv)
if (!priv)
{
return VPX_CODEC_MEM_ERROR;
}
ctx->priv = &priv->base;
ctx->priv->sz = sizeof(*ctx->priv);
ctx->priv->iface = ctx->iface;
@ -527,6 +530,12 @@ static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx)
if (priv->cx_data_sz < 4096) priv->cx_data_sz = 4096;
priv->cx_data = malloc(priv->cx_data_sz);
if (!priv->cx_data)
{
return VPX_CODEC_MEM_ERROR;
}
priv->deprecated_mode = NO_MODE_SET;
vp8_initialize();
@ -535,7 +544,9 @@ static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx)
if (!res)
{
set_vp8e_config(&ctx->priv->alg_priv->oxcf, ctx->priv->alg_priv->cfg, ctx->priv->alg_priv->vp8_cfg);
set_vp8e_config(&ctx->priv->alg_priv->oxcf,
ctx->priv->alg_priv->cfg,
ctx->priv->alg_priv->vp8_cfg);
optr = vp8_create_compressor(&ctx->priv->alg_priv->oxcf);
if (!optr)
@ -544,7 +555,6 @@ static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx)
ctx->priv->alg_priv->cpi = optr;
}
}
}
return res;
}