grain_table.c: add missing alloc checks

Bug: aomedia:3276
Change-Id: I60c61f45ce77ea84da33dfb4b9f80729143eac1f
diff --git a/aom_dsp/grain_table.c b/aom_dsp/grain_table.c
index 03b25c8..ad9bdb9 100644
--- a/aom_dsp/grain_table.c
+++ b/aom_dsp/grain_table.c
@@ -191,11 +191,14 @@
   }
 }
 
+// TODO(https://crbug.com/aomedia/3228): Update this function to return an
+// integer status.
 void aom_film_grain_table_append(aom_film_grain_table_t *t, int64_t time_stamp,
                                  int64_t end_time,
                                  const aom_film_grain_t *grain) {
   if (!t->tail || memcmp(grain, &t->tail->params, sizeof(*grain))) {
     aom_film_grain_table_entry_t *new_tail = aom_malloc(sizeof(*new_tail));
+    if (!new_tail) return;
     memset(new_tail, 0, sizeof(*new_tail));
     if (t->tail) t->tail->next = new_tail;
     if (!t->head) t->head = new_tail;
@@ -245,6 +248,7 @@
       } else {
         aom_film_grain_table_entry_t *new_entry =
             aom_malloc(sizeof(*new_entry));
+        if (!new_entry) return 0;
         new_entry->next = entry->next;
         new_entry->start_time = end_time;
         new_entry->end_time = entry->end_time;
@@ -290,6 +294,11 @@
   aom_film_grain_table_entry_t *prev_entry = NULL;
   while (!feof(file)) {
     aom_film_grain_table_entry_t *entry = aom_malloc(sizeof(*entry));
+    if (!entry) {
+      aom_internal_error(error_info, AOM_CODEC_MEM_ERROR,
+                         "Unable to allocate grain table entry");
+      break;
+    }
     memset(entry, 0, sizeof(*entry));
     grain_table_entry_read(file, error_info, entry);
     entry->next = NULL;