diff options
author | Alexis Hildebrandt <afh@surryhill.net> | 2022-10-01 20:32:41 +0200 |
---|---|---|
committer | Martin Michlmayr <tbm@cyrius.com> | 2022-10-02 10:19:52 +0800 |
commit | 401fede79815c3396b9a915622347424ef76ac8d (patch) | |
tree | c5e689618beddbed510b9851b4d713fa7e3aaa4b /src | |
parent | 1f79792ec824d1792f76c4ff6d47e32affab7c8a (diff) | |
download | fork-ledger-401fede79815c3396b9a915622347424ef76ac8d.tar.gz fork-ledger-401fede79815c3396b9a915622347424ef76ac8d.tar.bz2 fork-ledger-401fede79815c3396b9a915622347424ef76ac8d.zip |
Handle return value of PyUnicode_READY
to ensure access macros are only called on "legacy" unicode string
objects that are "ready".
See https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_READY
Diffstat (limited to 'src')
-rw-r--r-- | src/py_utils.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/py_utils.cc b/src/py_utils.cc index cd44aa93..8765bb78 100644 --- a/src/py_utils.cc +++ b/src/py_utils.cc @@ -134,7 +134,8 @@ struct string_from_python PyUnicode_GET_SIZE(obj_ptr); #endif #if PY_MINOR_VERSION < 12 - PyUnicode_READY(obj_ptr); + if (PyUnicode_READY(obj_ptr)) + return; #endif switch (PyUnicode_KIND(obj_ptr)) { case PyUnicode_1BYTE_KIND: { |