Browse Source

Fixed RandomGenerator.random crashing if a nil 'self' is passed. (closes issue #1116)

It still doesn't generate a proper error message if a non-RandomGenerator 'self' is used, however.
Alex Szpakowski 9 years ago
parent
commit
a9e10dcadf
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/modules/math/wrap_RandomGenerator.cpp

+ 1 - 1
src/modules/math/wrap_RandomGenerator.cpp

@@ -126,7 +126,7 @@ static FFI_RandomGenerator ffifuncs =
 	[](Proxy *p) -> double // random()
 	{
 		// FIXME: We need better type-checking...
-		if (!typeFlags[p->type][MATH_RANDOM_GENERATOR_ID])
+		if (p == nullptr || !typeFlags[p->type][MATH_RANDOM_GENERATOR_ID])
 			return 0.0;
 
 		RandomGenerator *rng = (RandomGenerator *) p->object;