diff options
author | Sam Gross <colesbury@gmail.com> | 2025-01-02 19:02:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-02 19:02:54 (GMT) |
commit | 8eebe4e6d02bb4ad3f1ca6c52624186903dce893 (patch) | |
tree | 1f490d057becb68f109b960e38afbed6ee58fa51 /Objects | |
parent | c9356feef28e6dfc4dc32830d3427a5ae0e426e2 (diff) | |
download | cpython-8eebe4e6d02bb4ad3f1ca6c52624186903dce893.zip cpython-8eebe4e6d02bb4ad3f1ca6c52624186903dce893.tar.gz cpython-8eebe4e6d02bb4ad3f1ca6c52624186903dce893.tar.bz2 |
gh-128212: Fix race in `_PyUnicode_CheckConsistency` (GH-128367)
There was a data race on the utf8 field between `PyUnicode_SET_UTF8` and
`_PyUnicode_CheckConsistency`. Use the `_PyUnicode_UTF8()` accessor,
which uses an atomic load internally, to avoid the data race.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/unicodeobject.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 1aab9cf..9f0a4d4 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -688,7 +688,7 @@ _PyUnicode_CheckConsistency(PyObject *op, int check_content) || kind == PyUnicode_2BYTE_KIND || kind == PyUnicode_4BYTE_KIND); CHECK(ascii->state.ascii == 0); - CHECK(compact->utf8 != data); + CHECK(_PyUnicode_UTF8(op) != data); } else { PyUnicodeObject *unicode = _PyUnicodeObject_CAST(op); |