--- monster2.old	Mon Jun 12 15:08:56 2000
+++ monster2.c	Wed Feb  7 11:15:44 2001
@@ -1843,9 +1843,10 @@
 	int px = p_ptr->px;
 
 	int y, x;
+	int	attempts_left = 10000;
 
 	/* Find a legal, distant, unoccupied, space */
-	while (1)
+	while (--attempts_left)
 	{
 		/* Pick a location */
 		y = rand_int(DUNGEON_HGT);
@@ -1856,6 +1857,16 @@
 
 		/* Accept far away grids */
 		if (distance(y, x, py, px) > dis) break;
+	}
+
+	if (!attempts_left)
+	{
+		if (cheat_xtra || cheat_hear)
+		{
+			msg_print("Warning! Could not allocate a new monster.");
+		}
+
+		return FALSE;
 	}
 
 	/* Attempt to place the monster, allow groups */
