Index: generic/threadSpCmd.c
===================================================================
RCS file: /cvsroot/tcl/thread/generic/threadSpCmd.c,v
retrieving revision 1.28
diff -u -r1.28 threadSpCmd.c
--- generic/threadSpCmd.c	3 Dec 2008 20:55:35 -0000	1.28
+++ generic/threadSpCmd.c	3 May 2009 23:02:03 -0000
@@ -1003,15 +1004,16 @@
 static int
 RemoveMutex(char *name, int len)
 {
-    SpMutex *mutexPtr = (SpMutex*)RemoveAnyItem(SP_MUTEX, name, len);
-
+    SpMutex *mutexPtr = GetMutex(name, len);
     if (mutexPtr == NULL) {
         return -1;
     }
     if (!SpMutexFinalize(mutexPtr)) {
+        PutMutex(mutexPtr);
         return 0;
     }
-
+    PutMutex(mutexPtr);
+    RemoveAnyItem(SP_MUTEX, name, len);
     Tcl_Free((char*)mutexPtr);
 
     return 1;
