]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #29044: Fix a use-after-free in string '%c' formatter.
authorXiang Zhang <angwerzx@126.com>
Thu, 22 Dec 2016 07:30:47 +0000 (15:30 +0800)
committerXiang Zhang <angwerzx@126.com>
Thu, 22 Dec 2016 07:30:47 +0000 (15:30 +0800)
Objects/unicodeobject.c

index ab261cc953f30bcc4232c23df1bc84ead300e168..57878308b7b2481a6c947f71b56b02664e9e89d8 100644 (file)
@@ -14213,11 +14213,12 @@ formatchar(PyObject *v)
             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;