From c2661e6189ab2833bf32fa723cc427e64c026839 Mon Sep 17 00:00:00 2001 From: AN Long Date: Mon, 22 Jun 2026 02:16:30 +0900 Subject: [PATCH] gh-151845: Fix formatfloat() return-value contract in unicode_format.c (#151846) Fix formatfloat() return-value contract in unicode_format.c --- Objects/unicode_format.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Objects/unicode_format.c b/Objects/unicode_format.c index e2790c8c1d43..1d6f3f7d9a6f 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; } -- 2.47.3