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
This commit is contained in:
bsalomon@google.com 2013-01-25 19:19:20 +00:00
parent 713276b143
commit 6d5d08f14f

View File

@ -69,7 +69,12 @@ public:
*/
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