fixed nasty bug #156087 Daniel

* threads.c: fixed nasty bug #156087
Daniel
diff --git a/threads.c b/threads.c
index b4a4cdc..d7bd783 100644
--- a/threads.c
+++ b/threads.c
@@ -359,6 +359,9 @@
  ************************************************************************/
 
 #ifdef LIBXML_THREAD_ENABLED
+#ifdef xmlLastError
+#undef xmlLastError
+#endif
 /**
  * xmlFreeGlobalState:
  * @state:  a thread global state
@@ -369,8 +372,10 @@
 static void
 xmlFreeGlobalState(void *state)
 {
-	/* free any memory allocated in the thread's xmlLastError */
-	xmlResetLastError();
+    xmlGlobalState *gs = (xmlGlobalState *) state;
+
+    /* free any memory allocated in the thread's xmlLastError */
+    xmlResetError(&(gs->xmlLastError));
     free(state);
 }