[mono/mono] 2d18195d: Fix an NRE in System.Timers.Timer.Dispose ().

"alexrp ([email protected])" <[email protected]> Sat, 9 Nov 2013 01:19:46 +0000
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <000001423a717f16-fc057994-8e00-455d-a212-4c10b6dd1512-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/mono
  Compare: https://github.com/mono/mono/compare/55e766632fd6...2d18195d175b

   Commit: 2d18195d175b3cd5ec516064ce8930d881b9d86f
   Author: Alex Rønne Petersen <[email protected]> 
     Date: 2013-11-09 01:18:23 GMT
      URL: https://github.com/mono/mono/commit/2d18195d175b3cd5ec516064ce8930d881b9d86f

Fix an NRE in System.Timers.Timer.Dispose ().

This would happen because _lock is nullified by the GC during
finalization. Dispose () calls Close () which sets the Enabled
property to false, which then attempts to lock on _lock.

Changed paths:
  M mcs/class/System/System.Timers/Timer.cs

Modified: mcs/class/System/System.Timers/Timer.cs
===================================================================
@@ -159,7 +159,11 @@ public void Stop ()
 
 		protected override void Dispose (bool disposing)
 		{
-			Close ();
+			// If _lock is null, it means we're finalizing,
+			// in which case everything has been nulled anyway.
+			if (_lock != null)
+				Close ();
+
 			base.Dispose (disposing);
 		}
 
_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches