Fix for BLI_rng_shuffle_array noted by mont29

This commit is contained in:
Campbell Barton
2014-04-02 10:09:48 +11:00
parent da4b90a331
commit 1d9e0c373d

View File

@@ -140,15 +140,13 @@ void BLI_rng_shuffle_array(RNG *rng, void *data, unsigned int elem_size_i, unsig
unsigned int i = elem_tot;
void *temp;
if (elem_tot == 0) {
if (elem_tot <= 1) {
return;
}
temp = malloc(elem_size);
/* XXX Shouldn't it rather be "while (i--) {" ?
* Else we have no guaranty first (0) element has a chance to be shuffled... --mont29 */
while (--i) {
while (i--) {
unsigned int j = BLI_rng_get_uint(rng) % elem_tot;
if (i != j) {
void *iElem = (unsigned char *)data + i * elem_size_i;