Skip to content

Commit 6e77767

Browse files
serhiy-storchakamgorny
authored andcommitted
pythongh-133767: Fix use-after-free in the unicode-escape decoder with an error handler (pythonGH-129648) (pythonGH-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 9f69a58) (cherry picked from commit 6279eb8) (cherry picked from commit a75953b) (cherry picked from commit 0c33e5b) Co-authored-by: Serhiy Storchaka <[email protected]> Part-of: python#134345 Closes: python#134345 Signed-off-by: Michał Górny <[email protected]>
1 parent 79662d6 commit 6e77767

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Lib/test/test_codeccallbacks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import codecs
22
import html.entities
33
import itertools
4+
import re
45
import sys
56
import unicodedata
67
import unittest

0 commit comments

Comments
 (0)