cpython/Include/cpython
Serhiy Storchaka 8d35fd1b34
[3.9] gh-133767: Fix use-after-free in the unicode-escape decoder with an error handler (GH-129648) (GH-133944) (#134346)
* [3.9] gh-133767: Fix use-after-free in the unicode-escape decoder with an error handler (GH-129648) (GH-133944)

If the error handler is used, a new bytes object is created to set as
the object attribute of UnicodeDecodeError, and that bytes object then
replaces the original data. A pointer to the decoded data will became invalid
after destroying that temporary bytes object. So we need other way to return
the first invalid escape from _PyUnicode_DecodeUnicodeEscapeInternal().

_PyBytes_DecodeEscape() does not have such issue, because it does not
use the error handlers registry, but it should be changed for compatibility
with _PyUnicode_DecodeUnicodeEscapeInternal().
(cherry picked from commit 9f69a58623)
(cherry picked from commit 6279eb8c07)
(cherry picked from commit a75953b347)
(cherry picked from commit 0c33e5baed)
(cherry picked from commit 8b528cacbb)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-06-02 17:58:01 +02:00
..
abstract.h [3.9] bpo-40052: Fix alignment issue in PyVectorcall_Function() (GH-23999) (GH-24005) 2021-01-05 16:46:58 +01:00
bytearrayobject.h bpo-35134: Add Include/cpython/bytesobject.h file (GH-18494) 2020-02-12 23:54:31 +01:00
bytesobject.h [3.9] gh-133767: Fix use-after-free in the unicode-escape decoder with an error handler (GH-129648) (GH-133944) (#134346) 2025-06-02 17:58:01 +02:00
ceval.h bpo-40421: Add pyframe.h header file (GH-19755) 2020-04-28 16:32:48 +02:00
code.h bpo-40421: Add Include/cpython/code.h header file (GH-19756) 2020-04-28 17:07:12 +02:00
dictobject.h [3.9] Fix typos in the Include directory (GH-28745) (GH-28788) 2021-10-07 06:01:05 -07:00
fileobject.h bpo-41986: Add Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode back to limited API (GH-22621) 2020-10-10 07:32:09 -07:00
fileutils.h bpo-35134: Add Include/cpython/fileutils.h header file (GH-18493) 2020-02-12 23:55:09 +01:00
frameobject.h bpo-40421: Add PyFrame_GetBack() function (GH-19765) 2020-04-29 03:28:46 +02:00
import.h bpo-36710: Add tstate parameter in import.c (GH-14218) 2019-06-19 02:54:39 +02:00
initconfig.h bpo-40854: Allow overriding sys.platlibdir via PYTHONPLATLIBDIR env-var (GH-20605) (GH-20725) 2020-06-08 19:36:13 +02:00
interpreteridobject.h bpo-38005: Fixed comparing and creating of InterpreterID and ChannelID. (GH-15652) 2019-09-13 22:50:27 +03:00
listobject.h bpo-40428: Remove PyTuple_ClearFreeList() function (GH-19769) 2020-04-29 02:29:20 +02:00
methodobject.h bpo-38787: Add PyCFunction_CheckExact() macro for exact type checks (GH-20024) 2020-05-12 07:12:41 -07:00
object.h bpo-39465: Remove _PyUnicode_ClearStaticStrings() from C API (GH-20078) 2020-05-14 01:11:54 +02:00
objimpl.h bpo-40170: Convert PyObject_IS_GC() macro to a function (GH-19464) 2020-04-14 20:11:20 +02:00
pyerrors.h bpo-41098: Doc: Add missing deprecated directives (GH-21162) 2020-08-07 00:49:53 -07:00
pylifecycle.h bpo-40453: Add PyConfig._isolated_subinterpreter (GH-19820) 2020-05-01 11:33:44 +02:00
pymem.h bpo-36763: Add PyMemAllocatorName (GH-13387) 2019-05-17 15:20:52 +02:00
pystate.h bpo-39026: Fix Python.h when building with Xcode (GH-29488) (GH-29776) 2021-11-26 10:59:31 +01:00
sysmodule.h bpo-38644: Add _PySys_Audit() which takes tstate (GH-19180) 2020-03-26 18:57:32 +01:00
traceback.h bpo-40421: Add pyframe.h header file (GH-19755) 2020-04-28 16:32:48 +02:00
tupleobject.h bpo-35134: Create Include/cpython/tupleobject.h (GH-10764) 2018-11-28 13:01:32 +01:00
unicodeobject.h [3.9] gh-133767: Fix use-after-free in the unicode-escape decoder with an error handler (GH-129648) (GH-133944) (#134346) 2025-06-02 17:58:01 +02:00