cpython/Parser
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
..
pegen [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
pgen Fix typo in the parser generator (GH-18603) 2020-03-09 02:58:24 +00:00
acceler.c fix warnings by adding more const (GH-12924) 2019-04-23 20:39:37 +09:00
asdl.py bpo-40528: Improve and clear several aspects of the ASDL definition code for the AST (GH-19952) 2020-05-06 15:29:32 +01:00
asdl_c.py [3.9] bpo-11105: Do not crash when compiling recursive ASTs (GH-20594) (GH-26522) 2021-06-03 22:22:34 +01:00
grammar1.c bpo-39882: Add _Py_FatalErrorFormat() function (GH-19157) 2020-03-25 19:27:36 +01:00
listnode.c bpo-40268: Remove a few pycore_pystate.h includes (GH-19510) 2020-04-14 17:52:15 +02:00
myreadline.c bpo-38156: Fix compiler warning in PyOS_StdioReadline() (GH-21721) 2020-08-03 17:56:54 -07:00
node.c bpo-40502: Initialize n->n_col_offset (GH-19988) 2020-05-08 17:58:28 -03:00
parser.c bpo-39882: Py_FatalError() logs the function name (GH-18819) 2020-03-07 00:54:20 +01:00
parser.h fix warnings by adding more const (GH-12924) 2019-04-23 20:39:37 +09:00
parsetok.c bpo-40335: Correctly handle multi-line strings in tokenize error scenarios (GH-19619) 2020-04-21 01:53:04 +01:00
Python.asdl bpo-40528: Improve and clear several aspects of the ASDL definition code for the AST (GH-19952) 2020-05-06 15:29:32 +01:00
token.c bpo-35975: Support parsing earlier minor versions of Python 3 (GH-12086) 2019-03-07 12:38:08 -08:00
tokenizer.c bpo-45738: Fix computation of error location for invalid continuation characters in the parser (GH-29550) (GH-29552) 2021-11-14 01:47:27 +00:00
tokenizer.h closes bpo-39721: Fix constness of members of tok_state struct. (GH-18600) 2020-02-27 18:44:52 -08:00