fastssim,fs_ctx_init: check alloc
Bug: aomedia:3276
Change-Id: Ie087e8be1e943b94327ed520db447a0e3a927738
diff --git a/aom_dsp/fastssim.c b/aom_dsp/fastssim.c
index ea58048..0ef0590 100644
--- a/aom_dsp/fastssim.c
+++ b/aom_dsp/fastssim.c
@@ -49,7 +49,7 @@
unsigned *col_buf;
};
-static void fs_ctx_init(fs_ctx *_ctx, int _w, int _h, int _nlevels) {
+static int fs_ctx_init(fs_ctx *_ctx, int _w, int _h, int _nlevels) {
unsigned char *data;
size_t data_size;
int lw;
@@ -73,6 +73,7 @@
lh = (lh + 1) >> 1;
}
data = (unsigned char *)malloc(data_size);
+ if (!data) return -1;
_ctx->level = (fs_level *)data;
_ctx->nlevels = _nlevels;
data += _nlevels * sizeof(*_ctx->level);
@@ -97,6 +98,7 @@
lh = (lh + 1) >> 1;
}
_ctx->col_buf = (unsigned *)data;
+ return 0;
}
static void fs_ctx_clear(fs_ctx *_ctx) { free(_ctx->level); }
@@ -446,7 +448,7 @@
double ret;
int l;
ret = 1;
- fs_ctx_init(&ctx, _w, _h, FS_NLEVELS);
+ if (fs_ctx_init(&ctx, _w, _h, FS_NLEVELS)) return 99.0;
fs_downsample_level0(&ctx, _src, _systride, _dst, _dystride, _w, _h, _shift,
buf_is_hbd);
for (l = 0; l < FS_NLEVELS - 1; l++) {