diff --git a/src/xpdev/genwrap.c b/src/xpdev/genwrap.c
index c715812591e9d1698289001704d332f78d55091e..477053581552830d6dbd62c28026546f6faf68bb 100644
--- a/src/xpdev/genwrap.c
+++ b/src/xpdev/genwrap.c
@@ -275,9 +275,11 @@ unsigned DLLCALL xp_randomize(void)
 int DLLCALL xp_random(int n)
 {
 #ifdef HAS_RANDOM_FUNC
+	if(n<2)
+		return(0);
 	return(random()%n);
 #else
-	float f;
+	float f=0;
 
 	if(n<2)
 		return(0);