Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 77eede3

Browse files
Issue python#28426: Fixed potential crash in PyUnicode_AsDecodedObject() in debug build.
1 parent 068534a commit 77eede3

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Release date: TBA
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #28426: Fixed potential crash in PyUnicode_AsDecodedObject() in debug
14+
build.
15+
1316
Library
1417
-------
1518

Objects/unicodeobject.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3059,24 +3059,16 @@ PyUnicode_AsDecodedObject(PyObject *unicode,
30593059
const char *encoding,
30603060
const char *errors)
30613061
{
3062-
PyObject *v;
3063-
30643062
if (!PyUnicode_Check(unicode)) {
30653063
PyErr_BadArgument();
3066-
goto onError;
3064+
return NULL;
30673065
}
30683066

30693067
if (encoding == NULL)
30703068
encoding = PyUnicode_GetDefaultEncoding();
30713069

30723070
/* Decode via the codec registry */
3073-
v = PyCodec_Decode(unicode, encoding, errors);
3074-
if (v == NULL)
3075-
goto onError;
3076-
return unicode_result(v);
3077-
3078-
onError:
3079-
return NULL;
3071+
return PyCodec_Decode(unicode, encoding, errors);
30803072
}
30813073

30823074
PyObject *

0 commit comments

Comments
 (0)