Index: /trunk/src/VBox/Runtime/common/misc/thread.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/misc/thread.cpp	(revision 25659)
+++ /trunk/src/VBox/Runtime/common/misc/thread.cpp	(revision 25660)
@@ -524,5 +524,4 @@
 }
 
-
 /**
  * Release a per thread data structure.
@@ -542,5 +541,8 @@
     }
     else
+    {
         cRefs = 0;
+        AssertFailed();
+    }
     return cRefs;
 }
@@ -571,5 +573,5 @@
 
     /*
-     * Invalidate the thread structure and free it.
+     * Invalidate the thread structure.
      */
 #ifdef IN_RING3
@@ -585,6 +587,4 @@
     pThread->EventTerminated = NIL_RTSEMEVENTMULTI;
 
-    RTMemFree(pThread);
-
 #ifdef IN_RING3
     rtLockValidatorSerializeDestructLeave();
@@ -592,9 +592,11 @@
 
     /*
-     * Destroy semaphore resources.
+     * Destroy semaphore resources and free the bugger.
      */
     RTSemEventMultiDestroy(hEvt1);
     if (hEvt2 != NIL_RTSEMEVENTMULTI)
         RTSemEventMultiDestroy(hEvt2);
+
+    RTMemFree(pThread);
 }
 
