summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-06-21 18:35:22 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-07-08 18:52:43 +0000
commitfc95af3621c8d135d613e1fff82c0613bf281c87 (patch)
tree8015237a57e8fbbba6052f33743af9dc89d16b16
parentd8688d44840dd3f2324769d10b927c442b42e2c0 (diff)
QSimpleTextCodec: fix load memory order of atomic pointer
The pointer value is not the only data we're interested in, but instead points to indirect data, so we need a release fence on store (present) and a corresponding acquire fence on load (was missing). Change-Id: I51f8251c0c7f4056192880430f2be5e0836dbed6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 6f84829031f318bfda1deff5f409b5ea6c6a5c5f) (cherry picked from commit 4cc6e1419294a729e53d698bace2254903c1429b) Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
-rw-r--r--src/corelib/codecs/qsimplecodec.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/codecs/qsimplecodec.cpp b/src/corelib/codecs/qsimplecodec.cpp
index 9ab545d783..16a9b8a7c3 100644
--- a/src/corelib/codecs/qsimplecodec.cpp
+++ b/src/corelib/codecs/qsimplecodec.cpp
@@ -610,7 +610,7 @@ QSimpleTextCodec::QSimpleTextCodec(int i) : forwardIndex(i), reverseMap(0)
QSimpleTextCodec::~QSimpleTextCodec()
{
- delete reverseMap.load();
+ delete reverseMap.loadAcquire();
}
static QByteArray *buildReverseMap(int forwardIndex)
@@ -662,12 +662,12 @@ QByteArray QSimpleTextCodec::convertFromUnicode(const QChar *in, int length, Con
const char replacement = (state && state->flags & ConvertInvalidToNull) ? 0 : '?';
int invalid = 0;
- QByteArray *rmap = reverseMap.load();
+ QByteArray *rmap = reverseMap.loadAcquire();
if (!rmap){
rmap = buildReverseMap(this->forwardIndex);
if (!reverseMap.testAndSetRelease(0, rmap)) {
delete rmap;
- rmap = reverseMap.load();
+ rmap = reverseMap.loadAcquire();
}
}