]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.15] gh-151845: Fix formatfloat() return-value contract in unicode_format.c (GH...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 21 Jun 2026 17:43:01 +0000 (19:43 +0200)
committerGitHub <noreply@github.com>
Sun, 21 Jun 2026 17:43:01 +0000 (17:43 +0000)
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 <aisk@users.noreply.github.com>
Objects/unicode_format.c

index e2790c8c1d4343d9b5fcbc123dd68100c9bdbdfd..1d6f3f7d9a6f6a00c1f2f574d4f3958a29801f0c 100644 (file)
@@ -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;
 }