[Scummvm-git-logs] scummvm master -> 93e8e2a8c54354e5fc4d6bccb997c89c9200c309
criezy
criezy at scummvm.org
Wed Mar 31 21:54:09 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
93e8e2a8c5 COMMON: Fix regression on String thread safety
Commit: 93e8e2a8c54354e5fc4d6bccb997c89c9200c309
https://github.com/scummvm/scummvm/commit/93e8e2a8c54354e5fc4d6bccb997c89c9200c309
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-03-31T22:50:11+01:00
Commit Message:
COMMON: Fix regression on String thread safety
The string memory pool mutex lock/unlock were lost during the
merge of String and U32String. This caused the cloud feature
to randomly crash for example when synchronizing savegames or
downloading game data.
Changed paths:
common/base-str.cpp
diff --git a/common/base-str.cpp b/common/base-str.cpp
index 6e65c1156c..db61b15548 100644
--- a/common/base-str.cpp
+++ b/common/base-str.cpp
@@ -181,12 +181,14 @@ TEMPLATE
void BASESTRING::incRefCount() const {
assert(!isStorageIntern());
if (_extern._refCount == nullptr) {
+ lockMemoryPoolMutex();
if (g_refCountPool == nullptr) {
g_refCountPool = new MemoryPool(sizeof(int));
assert(g_refCountPool);
}
_extern._refCount = (int *)g_refCountPool->allocChunk();
+ unlockMemoryPoolMutex();
*_extern._refCount = 2;
} else {
++(*_extern._refCount);
@@ -205,8 +207,10 @@ void BASESTRING::decRefCount(int *oldRefCount) {
// The ref count reached zero, so we free the string storage
// and the ref count storage.
if (oldRefCount) {
+ lockMemoryPoolMutex();
assert(g_refCountPool);
g_refCountPool->freeChunk(oldRefCount);
+ unlockMemoryPoolMutex();
}
// Coverity thinks that we always free memory, as it assumes
// (correctly) that there are cases when oldRefCount == 0
More information about the Scummvm-git-logs
mailing list