[Python-checkins] cpython (3.5): Issue #29044: Fix a use-after-free in string '%c' formatter.

xiang.zhang python-checkins at python.org
Thu Dec 22 02:38:06 EST 2016


https://hg.python.org/cpython/rev/e572c323fe53
changeset:   105778:e572c323fe53
branch:      3.5
parent:      105775:eb8667196f93
user:        Xiang Zhang <angwerzx at 126.com>
date:        Thu Dec 22 15:30:47 2016 +0800
summary:
  Issue #29044: Fix a use-after-free in string '%c' formatter.

files:
  Objects/unicodeobject.c |  7 ++++---
  1 files changed, 4 insertions(+), 3 deletions(-)


diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -14213,11 +14213,12 @@
             if (iobj == NULL) {
                 goto onError;
             }
-            v = iobj;
+            x = PyLong_AsLong(iobj);
             Py_DECREF(iobj);
         }
-        /* Integer input truncated to a character */
-        x = PyLong_AsLong(v);
+        else {
+            x = PyLong_AsLong(v);
+        }
         if (x == -1 && PyErr_Occurred())
             goto onError;
 

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


More information about the Python-checkins mailing list