summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Zern <jzern@google.com>2016-02-18 18:50:58 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-02-18 18:50:58 +0000
commitc8fa9e9d53fb69aa34135dcbde59368beb03ceb5 (patch)
treee8884202886b7be83f43471e17a31970aa8d851b
parent4950dbceaf22f0faefabdc61bb168c7bac1ab510 (diff)
parent02fe3ae907c0a4fe71849564365f06f3b927df93 (diff)
downloadlibvpx-c8fa9e9d53fb69aa34135dcbde59368beb03ceb5.tar
libvpx-c8fa9e9d53fb69aa34135dcbde59368beb03ceb5.tar.gz
libvpx-c8fa9e9d53fb69aa34135dcbde59368beb03ceb5.tar.bz2
libvpx-c8fa9e9d53fb69aa34135dcbde59368beb03ceb5.zip
Merge changes from topic 'vp8-missing-alloc-checks'
* changes: vp8_dx_iface: add missing alloc checks vp8/onyx_if: add missing alloc checks vp8/denoising: add missing alloc check
-rw-r--r--vp8/encoder/denoising.c5
-rw-r--r--vp8/encoder/onyx_if.c16
-rw-r--r--vp8/vp8_dx_iface.c7
3 files changed, 20 insertions, 8 deletions
diff --git a/vp8/encoder/denoising.c b/vp8/encoder/denoising.c
index 2a21943fe..113865fe8 100644
--- a/vp8/encoder/denoising.c
+++ b/vp8/encoder/denoising.c
@@ -440,6 +440,11 @@ int vp8_denoiser_allocate(VP8_DENOISER *denoiser, int width, int height,
denoiser->yv12_last_source.frame_size);
denoiser->denoise_state = vpx_calloc((num_mb_rows * num_mb_cols), 1);
+ if (!denoiser->denoise_state)
+ {
+ vp8_denoiser_free(denoiser);
+ return 1;
+ }
memset(denoiser->denoise_state, 0, (num_mb_rows * num_mb_cols));
vp8_denoiser_set_parameters(denoiser, mode);
denoiser->nmse_source_diff = 0;
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c
index 5a4b37dcf..93c457008 100644
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -1318,9 +1318,11 @@ void vp8_alloc_compressor_data(VP8_COMP *cpi)
#if CONFIG_TEMPORAL_DENOISING
if (cpi->oxcf.noise_sensitivity > 0) {
vp8_denoiser_free(&cpi->denoiser);
- vp8_denoiser_allocate(&cpi->denoiser, width, height,
- cm->mb_rows, cm->mb_cols,
- cpi->oxcf.noise_sensitivity);
+ if (vp8_denoiser_allocate(&cpi->denoiser, width, height,
+ cm->mb_rows, cm->mb_cols,
+ cpi->oxcf.noise_sensitivity))
+ vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
+ "Failed to allocate denoiser");
}
#endif
}
@@ -1832,9 +1834,11 @@ void vp8_change_config(VP8_COMP *cpi, VP8_CONFIG *oxcf)
{
int width = (cpi->oxcf.Width + 15) & ~15;
int height = (cpi->oxcf.Height + 15) & ~15;
- vp8_denoiser_allocate(&cpi->denoiser, width, height,
- cm->mb_rows, cm->mb_cols,
- cpi->oxcf.noise_sensitivity);
+ if (vp8_denoiser_allocate(&cpi->denoiser, width, height,
+ cm->mb_rows, cm->mb_cols,
+ cpi->oxcf.noise_sensitivity))
+ vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
+ "Failed to allocate denoiser");
}
}
#endif
diff --git a/vp8/vp8_dx_iface.c b/vp8/vp8_dx_iface.c
index a12a2ad0e..9b58f8186 100644
--- a/vp8/vp8_dx_iface.c
+++ b/vp8/vp8_dx_iface.c
@@ -67,10 +67,11 @@ struct vpx_codec_alg_priv
FRAGMENT_DATA fragments;
};
-static void vp8_init_ctx(vpx_codec_ctx_t *ctx)
+static int vp8_init_ctx(vpx_codec_ctx_t *ctx)
{
vpx_codec_alg_priv_t *priv =
(vpx_codec_alg_priv_t *)vpx_calloc(1, sizeof(*priv));
+ if (!priv) return 1;
ctx->priv = (vpx_codec_priv_t *)priv;
ctx->priv->init_flags = ctx->init_flags;
@@ -85,6 +86,8 @@ static void vp8_init_ctx(vpx_codec_ctx_t *ctx)
priv->cfg = *ctx->config.dec;
ctx->config.dec = &priv->cfg;
}
+
+ return 0;
}
static vpx_codec_err_t vp8_init(vpx_codec_ctx_t *ctx,
@@ -103,7 +106,7 @@ static vpx_codec_err_t vp8_init(vpx_codec_ctx_t *ctx,
* information becomes known.
*/
if (!ctx->priv) {
- vp8_init_ctx(ctx);
+ if (vp8_init_ctx(ctx)) return VPX_CODEC_MEM_ERROR;
priv = (vpx_codec_alg_priv_t *)ctx->priv;
/* initialize number of fragments to zero */