examples/inspect.c: add missing alloc check
Bug: aomedia:3276
Change-Id: I6605bcda0452fc71acab6ed3bf6c5805f2ab5b37
diff --git a/av1/decoder/inspection.c b/av1/decoder/inspection.c
index b706c45..288d69a 100644
--- a/av1/decoder/inspection.c
+++ b/av1/decoder/inspection.c
@@ -8,6 +8,10 @@
* Media Patent License 1.0 was not distributed with this source code in the
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
#include "av1/decoder/decoder.h"
#include "av1/decoder/inspection.h"
#include "av1/common/enums.h"
@@ -18,6 +22,10 @@
fd->mi_rows = mi_rows;
fd->mi_grid = (insp_mi_data *)aom_malloc(sizeof(insp_mi_data) * fd->mi_rows *
fd->mi_cols);
+ if (!fd->mi_grid) {
+ fprintf(stderr, "Error allocating inspection data\n");
+ abort();
+ }
}
void ifd_init(insp_frame_data *fd, int frame_width, int frame_height) {
diff --git a/examples/inspect.c b/examples/inspect.c
index 0a2e962..8e7213a 100644
--- a/examples/inspect.c
+++ b/examples/inspect.c
@@ -623,6 +623,10 @@
// We allocate enough space and hope we don't write out of bounds. Totally
// unsafe but this speeds things up, especially when compiled to Javascript.
char *buffer = aom_malloc(MAX_BUFFER);
+ if (!buffer) {
+ fprintf(stderr, "Error allocating inspect info buffer\n");
+ abort();
+ }
char *buf = buffer;
buf += put_str(buf, "{\n");
if (layers & BLOCK_SIZE_LAYER) {