From 1929407406966f9f2093a9e6b421cad39361dbb4 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 5 Oct 2012 00:09:33 +0200 Subject: [PATCH] Fix PyUnicode_Format(): return NULL if PyUnicode_READY(uformat) failed This error cannot occur in practice: PyUnicode_FromObject() always return a "ready" string. --- Objects/unicodeobject.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 0da565a612b..87ac044e1c4 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -13442,8 +13442,10 @@ PyUnicode_Format(PyObject *format, PyObject *args) uformat = PyUnicode_FromObject(format); if (uformat == NULL) return NULL; - if (PyUnicode_READY(uformat) == -1) + if (PyUnicode_READY(uformat) == -1) { Py_DECREF(uformat); + return NULL; + } fmt = PyUnicode_DATA(uformat); fmtkind = PyUnicode_KIND(uformat);