[Python-checkins] cpython (merge 3.4 -> 3.5): Issue #28426: Fixed potential crash in PyUnicode_AsDecodedObject() in debug

serhiy.storchaka python-checkins at python.org
Tue Oct 25 03:18:56 EDT 2016


https://hg.python.org/cpython/rev/74569ecd67e4
changeset:   104692:74569ecd67e4
branch:      3.5
parent:      104683:05b5e1aaedc5
parent:      104691:71dce630dc02
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Tue Oct 25 10:13:43 2016 +0300
summary:
  Issue #28426: Fixed potential crash in PyUnicode_AsDecodedObject() in debug build.

files:
  Misc/NEWS               |   3 +++
  Objects/unicodeobject.c |  12 ++----------
  2 files changed, 5 insertions(+), 10 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
 Core and Builtins
 -----------------
 
+- Issue #28426: Fixed potential crash in PyUnicode_AsDecodedObject() in debug
+  build.
+
 - Issue #23782: Fixed possible memory leak in _PyTraceback_Add() and exception
   loss in PyTraceBack_Here().
 
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -3026,24 +3026,16 @@
                           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 *

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list