[libxml2] xmlMemUsed is not thread-safe
- From: Daniel Veillard <veillard src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml2] xmlMemUsed is not thread-safe
- Date: Mon, 13 Apr 2015 08:47:21 +0000 (UTC)
commit 8985cde70901c62d3f0f04da225e73b7344a52d7
Author: Martin von Gagern <Martin vGagern gmx net>
Date: Mon Apr 13 16:32:14 2015 +0800
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
xmlmemory.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/xmlmemory.c b/xmlmemory.c
index a3dc737..f24fd6d 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]