From b6caf1606dfa35d843f567f8b9c33f54fa3581e5 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 17 Jul 2009 21:13:50 +0000 Subject: [PATCH] * If the world map module encounters an error, not all of the objects will be created and will therefore be null in the finally clause. Therefore, only dispose of objects that are not null in the finally clause. * fixes mantis #3848 --- .../CoreModules/World/WorldMap/WorldMapModule.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 1c7baa2129..3f640c5802 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -806,10 +806,18 @@ namespace OpenSim.Region.CoreModules.World.WorldMap finally { // Reclaim memory, these are unmanaged resources - mapTexture.Dispose(); - image.Dispose(); - imgstream.Close(); - imgstream.Dispose(); + // If we encountered an exception, one or more of these will be null + if (mapTexture != null) + mapTexture.Dispose(); + + if (image != null) + image.Dispose(); + + if (imgstream != null) + { + imgstream.Close(); + imgstream.Dispose(); + } } } else