summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin von Gagern <Martin.vGagern@gmx.net>2015-04-13 16:32:14 +0800
committerDaniel Veillard <veillard@redhat.com>2015-04-13 16:32:14 +0800
commit8985cde70901c62d3f0f04da225e73b7344a52d7 (patch)
tree6b7f166c4d17bea6732c109bd6e214bbbe1d0d8f
parent7607d9dd450275911eec5fcb66b69aacd13a4cc8 (diff)
downloadlibxml2-8985cde70901c62d3f0f04da225e73b7344a52d7.tar.gz
xmlMemUsed is not thread-safe
For https://bugzilla.gnome.org/show_bug.cgi?id=747437 just use the mutex to protect access to those variables
-rw-r--r--xmlmemory.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/xmlmemory.c b/xmlmemory.c
index a3dc737f..f24fd6d4 100644
--- a/xmlmemory.c
+++ b/xmlmemory.c
@@ -554,7 +554,12 @@ xmlMemoryStrdup(const char *str) {
int
xmlMemUsed(void) {
- return(debugMemSize);
+ int res;
+
+ xmlMutexLock(xmlMemMutex);
+ res = debugMemSize;
+ xmlMutexUnlock(xmlMemMutex);
+ return(res);
}
/**
@@ -567,7 +572,12 @@ xmlMemUsed(void) {
int
xmlMemBlocks(void) {
- return(debugMemBlocks);
+ int res;
+
+ xmlMutexLock(xmlMemMutex);
+ res = debugMemBlocks;
+ xmlMutexUnlock(xmlMemMutex);
+ return(res);
}
#ifdef MEM_LIST