diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2023-01-16 10:46:07 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-16 10:46:07 (GMT) |
commit | b1a74a182d8762bda51838401ac92b6ebad9632a (patch) | |
tree | 0719ae8d8916d2ee8e714c6461bcdfb6922ec042 | |
parent | b82049993f74185da71adf2eb8d6c8f15db063e1 (diff) | |
download | cpython-b1a74a182d8762bda51838401ac92b6ebad9632a.zip cpython-b1a74a182d8762bda51838401ac92b6ebad9632a.tar.gz cpython-b1a74a182d8762bda51838401ac92b6ebad9632a.tar.bz2 |
gh-101056: Fix memory leak in `formatfloat()` in `bytesobject.c` (#101057)
-rw-r--r-- | Objects/bytesobject.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 0fd10fa..ba2c2e9 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -434,8 +434,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; |