diff --git a/Source/Core/Map/MapSet.cs b/Source/Core/Map/MapSet.cs
index bf891eb..89be2b6 100644
--- a/Source/Core/Map/MapSet.cs
+++ b/Source/Core/Map/MapSet.cs
@@ -3387,6 +3387,9 @@ namespace CodeImp.DoomBuilder.Map
/// This finds the line closest to the specified position.
public static Linedef NearestLinedefRange(BlockMap selectionmap, Vector2D pos, float maxrange) //mxd
{
+ if (selectionmap == null)
+ return null;
+
Linedef closest = null;
float distance = float.MaxValue;
float maxrangesq = maxrange * maxrange;