https://github.com/python/cpython/commit/c2661e6189ab2833bf32fa723cc427e64c026839
commit: c2661e6189ab2833bf32fa723cc427e64c026839
branch: main
author: AN Long <[email protected]>
committer: sobolevn <[email protected]>
date: 2026-06-21T20:16:30+03:00
summary:

gh-151845: Fix formatfloat() return-value contract in unicode_format.c (#151846)

Fix formatfloat() return-value contract in unicode_format.c

files:
M Objects/unicode_format.c

diff --git a/Objects/unicode_format.c b/Objects/unicode_format.c
index e2790c8c1d4343d..1d6f3f7d9a6f6a0 100644
--- a/Objects/unicode_format.c
+++ b/Objects/unicode_format.c
@@ -159,8 +159,13 @@ formatfloat(PyObject *v,
             return -1;
         }
     }
-    else
+    else {
         *p_output = _PyUnicode_FromASCII(p, len);
+        if (*p_output == NULL) {
+            PyMem_Free(p);
+            return -1;
+        }
+    }
     PyMem_Free(p);
     return 0;
 }

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to