third_party/fastfeat: add missing alloc checks

Bug: aomedia:3276
Change-Id: I0236611f60a7a42bc93aaec8e11accb6667e1561
diff --git a/third_party/fastfeat/README.libaom b/third_party/fastfeat/README.libaom
index a732b0d..ce7ce70 100644
--- a/third_party/fastfeat/README.libaom
+++ b/third_party/fastfeat/README.libaom
@@ -38,3 +38,4 @@
 Remove Fast 10, 11 and 12
 Convert tabs to spaces
 Prefix global functions with "aom_"
+Add error checking
diff --git a/third_party/fastfeat/fast_9.c b/third_party/fastfeat/fast_9.c
index c0fdbe2..345c37f 100644
--- a/third_party/fastfeat/fast_9.c
+++ b/third_party/fastfeat/fast_9.c
@@ -2994,6 +2994,7 @@
   int n;
 
   int pixel[16];
+  if(!scores) return NULL;
   make_offsets(pixel, stride);
 
   for(n=0; n < num_corners; n++)
@@ -3012,6 +3013,7 @@
   int x, y;
 
   ret_corners = (xy*)malloc(sizeof(xy)*rsize);
+  if(!ret_corners) return NULL;
   make_offsets(pixel, stride);
 
   for(y=3; y < ysize - 3; y++)
@@ -5926,6 +5928,7 @@
       {
         rsize*=2;
         ret_corners = (xy*)realloc(ret_corners, sizeof(xy)*rsize);
+        if(!ret_corners) return NULL;
       }
       ret_corners[num_corners].x = x;
       ret_corners[num_corners].y = y;
diff --git a/third_party/fastfeat/nonmax.c b/third_party/fastfeat/nonmax.c
index 2e048e5..39ec18c 100644
--- a/third_party/fastfeat/nonmax.c
+++ b/third_party/fastfeat/nonmax.c
@@ -49,20 +49,28 @@
   int point_above = 0;
   int point_below = 0;
 
-
-  if(num_corners < 1)
+  *ret_num_nonmax = 0;
+  if(!(corners && scores) || num_corners < 1)
   {
-    *ret_num_nonmax = 0;
     return 0;
   }
 
   ret_nonmax = (xy*)malloc(num_corners * sizeof(xy));
+  if(!ret_nonmax)
+  {
+    return 0;
+  }
 
   /* Find where each row begins
      (the corners are output in raster scan order). A beginning of -1 signifies
      that there are no corners on that row. */
   last_row = corners[num_corners-1].y;
   row_start = (int*)malloc((last_row+1)*sizeof(int));
+  if(!row_start)
+  {
+    free(ret_nonmax);
+    return 0;
+  }
 
   for(i=0; i < last_row+1; i++)
     row_start[i] = -1;