From: Kevin Lubick Date: Mon, 14 Nov 2016 13:32:03 +0000 (-0500) Subject: Properly handle INT_MIN and related X-Git-Tag: submit/tizen/20180928.044319~73^2~88 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fb0ce926e6c95e2d56c654b88777cbe8916ba73f;p=platform%2Fupstream%2FlibSkiaSharp.git Properly handle INT_MIN and related BUG=skia:5967 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4751 Change-Id: Ie846560ebdaf11e1a5247842b3549ade1e100af2 Reviewed-on: https://skia-review.googlesource.com/4751 Reviewed-by: Kevin Lubick Commit-Queue: Kevin Lubick --- diff --git a/fuzz/Fuzz.h b/fuzz/Fuzz.h index 5cc8bd21d8..559addb7cf 100644 --- a/fuzz/Fuzz.h +++ b/fuzz/Fuzz.h @@ -99,15 +99,15 @@ inline void Fuzz::nextRange(T* n, Min min, Max max) { if (0 == range) { return; } else { - if (*n < 0) { - *n = *n * -1; - } - if (*n < 0) { - // abs(INT_MIN) = INT_MIN, so we check this to avoid accidental negatives. - *n = min; - return; - } - *n = min + *n % range; + if (*n < 0) { // Handle negatives + if (*n != std::numeric_limits::lowest()) { + *n *= -1; + } + else { + *n = std::numeric_limits::max(); + } + } + *n = min + (*n % range); } }