[Python-checkins] gh-101056: Fix memory leak in `formatfloat()` in `bytesobject.c` (GH-101057)
miss-islington
webhook-mailer at python.org
Mon Jan 16 06:12:59 EST 2023
https://github.com/python/cpython/commit/664141e34c4df3aed6c21996e2476175d136c06b
commit: 664141e34c4df3aed6c21996e2476175d136c06b
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2023-01-16T03:12:52-08:00
summary:
gh-101056: Fix memory leak in `formatfloat()` in `bytesobject.c` (GH-101057)
(cherry picked from commit b1a74a182d8762bda51838401ac92b6ebad9632a)
Co-authored-by: Nikita Sobolev <mail at sobolevn.me>
files:
M Objects/bytesobject.c
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index eaedb0b5689b..4bcb2eb49298 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -470,8 +470,10 @@ formatfloat(PyObject *v, int flags, int prec, int type,
len = strlen(p);
if (writer != NULL) {
str = _PyBytesWriter_Prepare(writer, str, len);
- if (str == NULL)
+ if (str == NULL) {
+ PyMem_Free(p);
return NULL;
+ }
memcpy(str, p, len);
PyMem_Free(p);
str += len;
More information about the Python-checkins
mailing list