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>
This commit is contained in:
parent
322ac72945
commit
6f84829031
@ -610,7 +610,7 @@ QSimpleTextCodec::QSimpleTextCodec(int i) : forwardIndex(i), reverseMap(0)
|
||||
|
||||
QSimpleTextCodec::~QSimpleTextCodec()
|
||||
{
|
||||
delete reverseMap.loadRelaxed();
|
||||
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.loadRelaxed();
|
||||
QByteArray *rmap = reverseMap.loadAcquire();
|
||||
if (!rmap){
|
||||
rmap = buildReverseMap(this->forwardIndex);
|
||||
if (!reverseMap.testAndSetRelease(0, rmap)) {
|
||||
delete rmap;
|
||||
rmap = reverseMap.loadRelaxed();
|
||||
rmap = reverseMap.loadAcquire();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user