Commit 50ff939c authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #28426: Fixed potential crash in PyUnicode_AsDecodedObject() in debug build.

parent e75b96da
...@@ -10,6 +10,9 @@ Release date: TBA ...@@ -10,6 +10,9 @@ Release date: TBA
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #28426: Fixed potential crash in PyUnicode_AsDecodedObject() in debug
build.
Library Library
------- -------
......
...@@ -3059,24 +3059,16 @@ PyUnicode_AsDecodedObject(PyObject *unicode, ...@@ -3059,24 +3059,16 @@ PyUnicode_AsDecodedObject(PyObject *unicode,
const char *encoding, const char *encoding,
const char *errors) const char *errors)
{ {
PyObject *v;
if (!PyUnicode_Check(unicode)) { if (!PyUnicode_Check(unicode)) {
PyErr_BadArgument(); PyErr_BadArgument();
goto onError; return NULL;
} }
if (encoding == NULL) if (encoding == NULL)
encoding = PyUnicode_GetDefaultEncoding(); encoding = PyUnicode_GetDefaultEncoding();
/* Decode via the codec registry */ /* Decode via the codec registry */
v = PyCodec_Decode(unicode, encoding, errors); return PyCodec_Decode(unicode, encoding, errors);
if (v == NULL)
goto onError;
return unicode_result(v);
onError:
return NULL;
} }
PyObject * PyObject *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment