mirror of https://github.com/python/cpython
gh-101056: Fix memory leak in `formatfloat()` in `bytesobject.c` (#101057)
This commit is contained in:
parent
b82049993f
commit
b1a74a182d
|
@ -434,8 +434,10 @@ formatfloat(PyObject *v, int flags, int prec, int type,
|
||||||
len = strlen(p);
|
len = strlen(p);
|
||||||
if (writer != NULL) {
|
if (writer != NULL) {
|
||||||
str = _PyBytesWriter_Prepare(writer, str, len);
|
str = _PyBytesWriter_Prepare(writer, str, len);
|
||||||
if (str == NULL)
|
if (str == NULL) {
|
||||||
|
PyMem_Free(p);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
memcpy(str, p, len);
|
memcpy(str, p, len);
|
||||||
PyMem_Free(p);
|
PyMem_Free(p);
|
||||||
str += len;
|
str += len;
|
||||||
|
|
Loading…
Reference in New Issue