Fix nextRangeU(0, MAX_UINT) div by zero.
R=reed@google.com
Review URL: https://codereview.appspot.com/7201058
git-svn-id: http://skia.googlecode.com/svn/trunk@7400 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/utils/SkRandom.h b/include/utils/SkRandom.h
index 73dc491..d5f3123 100644
--- a/include/utils/SkRandom.h
+++ b/include/utils/SkRandom.h
@@ -69,7 +69,12 @@
*/
uint32_t nextRangeU(uint32_t min, uint32_t max) {
SkASSERT(min <= max);
- return min + this->nextU() % (max - min + 1);
+ uint32_t range = max - min + 1;
+ if (0 == range) {
+ return this->nextU();
+ } else {
+ return min + this->nextU() % range;
+ }
}
/** Return the next pseudo random unsigned number, mapped to lie within