mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
gh-101056: Fix memory leak in formatfloat() in bytesobject.c (GH-101057)
(cherry picked from commit b1a74a182d)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
parent
b7b641a2ff
commit
664141e34c
1 changed files with 3 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue