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:
parent
713276b143
commit
6d5d08f14f
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user