Author: miguel
Date: 2007-07-18 20:20:40 -0400 (Wed, 18 Jul 2007)
New Revision: 82260

Modified:
   trunk/mcs/class/corlib/System.Runtime.InteropServices/ChangeLog
   trunk/mcs/class/corlib/System.Runtime.InteropServices/CriticalHandle.cs
   trunk/mcs/class/corlib/System.Runtime.InteropServices/SafeHandle.cs
Log:
2007-07-18  Miguel de Icaza  <[EMAIL PROTECTED]>

        * SafeHandle.cs: Harden this, do not call ReleaseHandle if the
        handle is invalid.

        * CriticalHandle.cs: Harden this, do not call ReleaseHandle if the
        handle is invalid. 




Modified: trunk/mcs/class/corlib/System.Runtime.InteropServices/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System.Runtime.InteropServices/ChangeLog     
2007-07-19 00:16:20 UTC (rev 82259)
+++ trunk/mcs/class/corlib/System.Runtime.InteropServices/ChangeLog     
2007-07-19 00:20:40 UTC (rev 82260)
@@ -1,3 +1,11 @@
+2007-07-18  Miguel de Icaza  <[EMAIL PROTECTED]>
+
+       * SafeHandle.cs: Harden this, do not call ReleaseHandle if the
+       handle is invalid.
+
+       * CriticalHandle.cs: Harden this, do not call ReleaseHandle if the
+       handle is invalid. 
+
 2007-07-06  Jonathan Chambers  <[EMAIL PROTECTED]>
 
        * ExtensibleClassFactory.cs: Fix ExtensibleClassFactory.

Modified: 
trunk/mcs/class/corlib/System.Runtime.InteropServices/CriticalHandle.cs
===================================================================
--- trunk/mcs/class/corlib/System.Runtime.InteropServices/CriticalHandle.cs     
2007-07-19 00:16:20 UTC (rev 82259)
+++ trunk/mcs/class/corlib/System.Runtime.InteropServices/CriticalHandle.cs     
2007-07-19 00:20:40 UTC (rev 82260)
@@ -52,8 +52,8 @@
                        if (IsInvalid)
                                return;
 
-                       if (disposing == true){
-                               if (ReleaseHandle ()) {
+                       if (disposing == true && !IsInvalid){
+                               if (!ReleaseHandle ()) {
                                        GC.SuppressFinalize (this);
                                } else {
                                        // Failed in release...

Modified: trunk/mcs/class/corlib/System.Runtime.InteropServices/SafeHandle.cs
===================================================================
--- trunk/mcs/class/corlib/System.Runtime.InteropServices/SafeHandle.cs 
2007-07-19 00:16:20 UTC (rev 82259)
+++ trunk/mcs/class/corlib/System.Runtime.InteropServices/SafeHandle.cs 
2007-07-19 00:20:40 UTC (rev 82260)
@@ -82,7 +82,7 @@
                                newcount = current-1;
                        } while (Interlocked.CompareExchange (ref refcount, 
newcount, current) != current);
 
-                       if (newcount == 0 && owns_handle){
+                       if (newcount == 0 && owns_handle && !IsInvalid){
                                ReleaseHandle ();
                                handle = invalid_handle_value;
                        }
@@ -143,7 +143,7 @@
                                newcount = current-1;
                        } while (Interlocked.CompareExchange (ref refcount, 
newcount, current) != current);
 
-                       if (newcount == 0 && owns_handle){
+                       if (newcount == 0 && owns_handle && !IsInvalid){
                                ReleaseHandle ();
                                handle = invalid_handle_value;
                        }
@@ -204,7 +204,7 @@
 
                ~SafeHandle ()
                {
-                       if (owns_handle){
+                       if (owns_handle && !IsInvalid){
                                ReleaseHandle ();
                                handle = invalid_handle_value;
                        }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to