]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-151845: Fix formatfloat() return-value contract in unicode_format.c (#151846)
authorAN Long <aisk@users.noreply.github.com>
Sun, 21 Jun 2026 17:16:30 +0000 (02:16 +0900)
committerGitHub <noreply@github.com>
Sun, 21 Jun 2026 17:16:30 +0000 (20:16 +0300)
Fix formatfloat() return-value contract in unicode_format.c

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;
 }