Index: ChangeLog
===================================================================
--- ChangeLog	(revision 3662)
+++ ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+Tue Nov 13 23:00:00 2007 Marc-Antoine Ruel <maruel@gmail.com>
+
+	* threads.c: __xmlGlobalInitMutexDestroy() will free 
+	  global_init_lock on Win32.
+  
 Tue Oct 30 21:24:55 CET 2007 Daniel Veillard <daniel@veillard.com>
 
 	* xmlmemory.c: xmlFree(NULL) should not crash in debug mode
Index: globals.c
===================================================================
--- globals.c	(revision 3662)
+++ globals.c	(working copy)
@@ -60,6 +60,7 @@
 	xmlFreeMutex(xmlThrDefMutex);
 	xmlThrDefMutex = NULL;
     }
+    __xmlGlobalInitMutexDestroy();
 }
 
 /************************************************************************
Index: libxml.h
===================================================================
--- libxml.h	(revision 3662)
+++ libxml.h	(working copy)
@@ -77,6 +77,7 @@
  */
 void __xmlGlobalInitMutexLock(void);
 void __xmlGlobalInitMutexUnlock(void);
+void __xmlGlobalInitMutexDestroy(void);
 
 #ifdef IN_LIBXML
 #ifdef __GNUC__
Index: threads.c
===================================================================
--- threads.c	(revision 3662)
+++ threads.c	(working copy)
@@ -451,6 +451,7 @@
 	 * section in the global_init_lock then discard the one
 	 * allocated by this thread. */
 	if (global_init_lock != cs) {
+	    DeleteCriticalSection(cs);
 	    free(cs);
 	}
     }
@@ -500,6 +501,24 @@
 #endif
 }
 
+/**
+ * xmlGlobalInitMutexDestroy
+ *
+ * Makes sure that the global initialization mutex is destroyed before
+ * application termination.
+ */
+void __xmlGlobalInitMutexDestroy(void)
+{
+#if defined HAVE_WIN32_THREADS
+    if (global_init_lock != NULL)
+    {
+	DeleteCriticalSection(global_init_lock);
+	free(global_init_lock);
+	global_init_lock = NULL;
+    }
+#endif
+}
+
 /************************************************************************
  *									*
  *			Per thread global state handling		*
