Issue #29044: Fix a use-after-free in string '%c' formatter.
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index ab261cc..5787830 100644
--- 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;