Add assertion, rewrite code to appease scan-build

Change-Id: I22d59aed1f40c58369751dac5a0ee8a7ada1c122
diff --git a/third_party/fastfeat/README.libaom b/third_party/fastfeat/README.libaom
index d658f99..6c227c9 100644
--- a/third_party/fastfeat/README.libaom
+++ b/third_party/fastfeat/README.libaom
@@ -40,3 +40,4 @@
 Prefix global functions with "aom_"
 Add error checking
 Add output argument to hold the scores of the detected features
+Add assertion and rewrite comparison to appease the scan-build static analyzer
diff --git a/third_party/fastfeat/nonmax.c b/third_party/fastfeat/nonmax.c
index bbc9462..428f74e 100644
--- a/third_party/fastfeat/nonmax.c
+++ b/third_party/fastfeat/nonmax.c
@@ -29,6 +29,7 @@
 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 // clang-format off
+#include <assert.h>
 #include <stdlib.h>
 #include "fast.h"
 
@@ -101,6 +102,7 @@
   {
     int score = scores[i];
     xy pos = corners[i];
+    assert(pos.y <= last_row);
 
     /*Check left */
     if(i > 0)
@@ -138,7 +140,7 @@
 
     /*Check below (if there is anything below)*/
     if(pos.y >= 0)
-      if (pos.y != last_row && row_start[pos.y + 1] != -1 && point_below < sz) /*Nothing below*/
+      if (pos.y + 1 < last_row+1 && row_start[pos.y + 1] != -1 && point_below < sz) /*Nothing below*/
       {
         if(corners[point_below].y < pos.y + 1)
           point_below = row_start[pos.y+1];