gh-101056: Fix memory leak in `formatfloat()` in `bytesobject.c` (#101057)

This commit is contained in:
Nikita Sobolev 2023-01-16 13:46:07 +03:00 committed by GitHub
parent b82049993f
commit b1a74a182d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

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