Merge pull request #29702 from KoBeWi/fix_random_crash
Validate parameters of randi_range()
This commit is contained in:
commit
b44488d823
|
@ -59,6 +59,9 @@ public:
|
||||||
|
|
||||||
_FORCE_INLINE_ int randi_range(int from, int to) {
|
_FORCE_INLINE_ int randi_range(int from, int to) {
|
||||||
unsigned int ret = randbase.rand();
|
unsigned int ret = randbase.rand();
|
||||||
|
if (to < from)
|
||||||
|
return ret % (from - to + 1) + to;
|
||||||
|
else
|
||||||
return ret % (to - from + 1) + from;
|
return ret % (to - from + 1) + from;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue