From 9d1cc66b6065e7aafc4e999a36c9ec680e4f13b7 Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Mon, 12 Dec 2016 15:43:51 -0500 Subject: Use unsigned arithmetic for SkBitmapProcStateAutoMapper bias To avoid undefined int underflow behavior. BUG=skia:6017 R=mtklein@google.com,reed@google.com Change-Id: Ib707ad5e1d87eda70525c56db14849c4164c5640 Reviewed-on: https://skia-review.googlesource.com/5861 Reviewed-by: Mike Klein Commit-Queue: Florin Malita --- src/core/SkBitmapProcState.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h index cdf02ea9e0..88e5193b2a 100644 --- a/src/core/SkBitmapProcState.h +++ b/src/core/SkBitmapProcState.h @@ -236,8 +236,11 @@ public: biasY = s.fFilterOneY >> 1; } - fX = SkScalarToFractionalInt(pt.x()) - SkFixedToFractionalInt(biasX); - fY = SkScalarToFractionalInt(pt.y()) - SkFixedToFractionalInt(biasY); + // punt to unsigned for defined underflow behavior + fX = (SkFractionalInt)((uint64_t)SkScalarToFractionalInt(pt.x()) - + (uint64_t)SkFixedToFractionalInt(biasX)); + fY = (SkFractionalInt)((uint64_t)SkScalarToFractionalInt(pt.y()) - + (uint64_t)SkFixedToFractionalInt(biasY)); if (scalarPoint) { scalarPoint->set(pt.x() - SkFixedToScalar(biasX), -- cgit v1.2.3