8000 gh-101056: Fix memory leak in `formatfloat()` in `bytesobject.c` (#10… · python/cpython@b1a74a1 · GitHub
[go: up one dir, main page]

Skip to content

Commit b1a74a1

Browse files
authored
gh-101056: Fix memory leak in formatfloat() in bytesobject.c (#101057)
1 parent b820499 commit b1a74a1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Objects/bytesobject.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,10 @@ formatfloat(PyObject *v, int flags, int prec, int type,
434434
len = strlen(p);
435435
if (writer != NULL) {
436436
str = _PyBytesWriter_Prepare(writer, str, len);
437-
if (str == NULL)
437+
if (str == NULL) {
438+
PyMem_Free(p);
438439
return NULL;
440+
}
439441
memcpy(str, p, len);
440442
PyMem_Free(p);
441443
str += len;

0 commit comments

Comments
 (0)
0