From 77eede35fc4409f3279af0fee91fdfb3fcc5a6ae Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 25 Oct 2016 10:07:51 +0300 Subject: [PATCH] Issue #28426: Fixed potential crash in PyUnicode_AsDecodedObject() in debug build. --- Misc/NEWS | 3 +++ Objects/unicodeobject.c | 12 ++---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS index 3c117db4c80..513989afee0 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Release date: TBA Core and Builtins ----------------- +- Issue #28426: Fixed potential crash in PyUnicode_AsDecodedObject() in debug + build. + Library ------- diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 193d898f1b2..7fad69541b3 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -3059,24 +3059,16 @@ PyUnicode_AsDecodedObject(PyObject *unicode, const char *encoding, const char *errors) { - PyObject *v; - if (!PyUnicode_Check(unicode)) { PyErr_BadArgument(); - goto onError; + return NULL; } if (encoding == NULL) encoding = PyUnicode_GetDefaultEncoding(); /* Decode via the codec registry */ - v = PyCodec_Decode(unicode, encoding, errors); - if (v == NULL) - goto onError; - return unicode_result(v); - - onError: - return NULL; + return PyCodec_Decode(unicode, encoding, errors); } PyObject *