diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index c5432bcd13..0ceb5ac266 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -732,6 +732,9 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
 
 	virtual void OnQueryTextFinished(char *str)
 	{
+		/* Was 'cancel' pressed? */
+		if (str == NULL) return;
+
 		int32 value;
 		if (!StrEmpty(str)) {
 			value = atoi(str);