diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-19 23:27:39 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-19 23:27:39 +0400 |
commit | 4fa92f1e5f51b67e20fdfeebcd4255e2e556f8f9 (patch) | |
tree | 94c8e718bec54d66cd89787f86c9b368ce4a2c3c | |
parent | 3dbc34049a65dadfcb830c8e351eb14cd6a7ade8 (diff) |
fix for error reported on IRC, sorting zero sized lists would cause a crash.
-rw-r--r-- | source/blender/blenlib/intern/rand.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/source/blender/blenlib/intern/rand.c b/source/blender/blenlib/intern/rand.c index 28dc5a696d5..6114ffdda80 100644 --- a/source/blender/blenlib/intern/rand.c +++ b/source/blender/blenlib/intern/rand.c @@ -111,7 +111,13 @@ float rng_getFloat(RNG *rng) void rng_shuffleArray(RNG *rng, void *data, int elemSize, int numElems) { int i = numElems; - void *temp = malloc(elemSize); + void *temp; + + if (numElems <= 0) { + return; + } + + temp = malloc(elemSize); while (--i) { int j = rng_getInt(rng)%numElems; |