From f5119a536a6ca97f282fb0e8d3f700369f907bb6 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Sun, 21 Jun 2026 19:43:01 +0200 Subject: [PATCH] [3.15] gh-151845: Fix formatfloat() return-value contract in unicode_format.c (GH-151846) (#151865) gh-151845: Fix formatfloat() return-value contract in unicode_format.c (GH-151846) Fix formatfloat() return-value contract in unicode_format.c (cherry picked from commit c2661e6189ab2833bf32fa723cc427e64c026839) Co-authored-by: AN Long --- 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