]> granicus.if.org Git - python/commitdiff
Fix PyUnicode_Format(): return NULL if PyUnicode_READY(uformat) failed
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 4 Oct 2012 22:09:33 +0000 (00:09 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 4 Oct 2012 22:09:33 +0000 (00:09 +0200)
This error cannot occur in practice: PyUnicode_FromObject() always return
a "ready" string.

Objects/unicodeobject.c

index 0da565a612b33c9741d5d104e5b73e922f3fe6f7..87ac044e1c43b95cbe5995dcbfb1c98e672676fd 100644 (file)
@@ -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);