diff options
author | Kevin Lubick <kjlubick@google.com> | 2016-11-15 16:07:02 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-11-16 19:17:19 +0000 |
commit | c9f0cc8700d57d57daab0aa4de1d5c367df99ceb (patch) | |
tree | f9b19fce3a2e081b28d016355646dc16694a7d20 /fuzz/Fuzz.h | |
parent | 1125a030c726854f94fd2b8eed49d1323fc1d038 (diff) |
Add back in min/max check on fuzzer range
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4798
Change-Id: Ia93b4eeea82dd04f0c6bd287f61d26086a0aa740
Reviewed-on: https://skia-review.googlesource.com/4798
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Diffstat (limited to 'fuzz/Fuzz.h')
-rw-r--r-- | fuzz/Fuzz.h | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/fuzz/Fuzz.h b/fuzz/Fuzz.h index 559addb7cf..8abbb2276a 100644 --- a/fuzz/Fuzz.h +++ b/fuzz/Fuzz.h @@ -95,20 +95,19 @@ inline void Fuzz::nextRange(float* f, float min, float max) { template <typename T, typename Min, typename Max> inline void Fuzz::nextRange(T* n, Min min, Max max) { this->next<T>(n); - T range = max - min + 1; - if (0 == range) { - return; - } else { - if (*n < 0) { // Handle negatives - if (*n != std::numeric_limits<T>::lowest()) { - *n *= -1; - } - else { - *n = std::numeric_limits<T>::max(); - } - } - *n = min + (*n % range); + if (min >= max) { + // Avoid misuse of nextRange + this->signalBug(); + } + if (*n < 0) { // Handle negatives + if (*n != std::numeric_limits<T>::lowest()) { + *n *= -1; + } + else { + *n = std::numeric_limits<T>::max(); + } } + *n = min + (*n % ((size_t)max - min + 1)); } template <typename T> |