From c8307cdf1e1f06f68fdf3f36d1facd295c77e88d Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 20 Apr 2012 23:35:11 +0100 Subject: [PATCH] Improve bitmap disposal to do null checks and not to potentially try disposal of uninitialized variables. This issue doesn't cause the mono 2.10.5 compiler to fail but appears to cause the windows compiler to fail. Resolves http://opensimulator.org/mantis/view.php?id=5973 --- .../World/Terrain/FileLoaders/GenericSystemDrawing.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs index 039c3fa4f8..d78ade5fa7 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs @@ -139,8 +139,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders string tempName = Path.GetTempFileName(); Bitmap existingBitmap = null; - Bitmap thisBitmap; - Bitmap newBitmap; + Bitmap thisBitmap = null; + Bitmap newBitmap = null; try { @@ -176,8 +176,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders if (existingBitmap != null) existingBitmap.Dispose(); - thisBitmap.Dispose(); - newBitmap.Dispose(); + if (thisBitmap != null) + thisBitmap.Dispose(); + + if (newBitmap != null) + newBitmap.Dispose(); if (File.Exists(tempName)) File.Delete(tempName);