8000 [3.11] gh-101056: Fix memory leak in `formatfloat()` in `bytesobject.c` (GH-101057) by miss-islington · Pull Request #101077 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.11] gh-101056: Fix memory leak in formatfloat() in bytesobject.c (GH-101057) #101077

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-101056: Fix memory leak in formatfloat() in bytesobject.c (GH-…
…101057)

(cherry picked from commit b1a74a1)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
  • Loading branch information
sobolevn authored and miss-islington committed Jan 16, 2023
commit 9d7c1e417d7c637dd17a180f8b7b40a92bfed6f7
4 changes: 3 additions & 1 deletion Objects/bytesobject.c
Original file line number Diff line number Diff line change
5CB1 Expand Up @@ -441,8 +441,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;
Expand Down
0