detect too many points

Bug:777318
Change-Id: Idb52688b6ee4ae020004400da995620c1f548559
Reviewed-on: https://skia-review.googlesource.com/73821
Commit-Queue: Mike Reed <mike@reedtribe.org>
Reviewed-by: Herb Derby <herb@google.com>
diff --git a/src/core/SkSafeMath.h b/src/core/SkSafeMath.h
index 91200fb..f781c2c 100644
--- a/src/core/SkSafeMath.h
+++ b/src/core/SkSafeMath.h
@@ -28,6 +28,21 @@
         return result;
     }
 
+    /**
+     *  Return a + b, unless this result is an overflow/underflow. In those cases, fOK will
+     *  be set to false, and it is undefined what this returns.
+     */
+    int addInt(int a, int b) {
+        if (b < 0 && a < std::numeric_limits<int>::min() - b) {
+            fOK = false;
+            return a;
+        } else if (b > 0 && a > std::numeric_limits<int>::max() - b) {
+            fOK = false;
+            return a;
+        }
+        return a + b;
+    }
+
 private:
     uint32_t mul32(uint32_t x, uint32_t y) {
         uint64_t bx = x;