From: AN Long Date: Sun, 21 Jun 2026 17:16:30 +0000 (+0900) Subject: gh-151845: Fix formatfloat() return-value contract in unicode_format.c (#151846) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2661e6189ab2833bf32fa723cc427e64c026839;p=thirdparty%2FPython%2Fcpython.git gh-151845: Fix formatfloat() return-value contract in unicode_format.c (#151846) Fix formatfloat() return-value contract in unicode_format.c --- 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; }