summaryrefslogtreecommitdiff
path: root/threads.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@redhat.com>2014-10-13 15:03:58 +0800
committerDaniel Veillard <veillard@redhat.com>2014-10-13 15:03:58 +0800
commit8854e4631844eac8dbae10cc32904f27d5268af7 (patch)
treeec85af451aeeed61d95266bab0faa2dd612360fa /threads.c
parent5018082b8c87fb0c1cac86a5e4f77333abf435a7 (diff)
downloadlibxml2-8854e4631844eac8dbae10cc32904f27d5268af7.tar.gz
Windows Critical sections not released correctly
For https://bugzilla.gnome.org/show_bug.cgi?id=737851 Based on report from mike.vanduzee@caris.com , we were missing calling LeaveCriticalSection() when count was down to 0 hence not freeing adequately the related resource.
Diffstat (limited to 'threads.c')
-rw-r--r--threads.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/threads.c b/threads.c
index f2f2703c..8921204b 100644
--- a/threads.c
+++ b/threads.c
@@ -378,7 +378,7 @@ xmlRMutexLock(xmlRMutexPtr tok)
pthread_mutex_unlock(&tok->lock);
#elif defined HAVE_WIN32_THREADS
EnterCriticalSection(&tok->cs);
- ++tok->count;
+ tok->count++;
#elif defined HAVE_BEOS_THREADS
if (tok->lock->tid == find_thread(NULL)) {
tok->count++;
@@ -414,8 +414,10 @@ xmlRMutexUnlock(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
}
pthread_mutex_unlock(&tok->lock);
#elif defined HAVE_WIN32_THREADS
- if (!--tok->count)
+ if (tok->count > 0) {
LeaveCriticalSection(&tok->cs);
+ tok->count--;
+ }
#elif defined HAVE_BEOS_THREADS
if (tok->lock->tid == find_thread(NULL)) {
tok->count--;