pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/d61fcf834d197f0113a6a507fdbecc1545d9d483

60c69660fa.css" /> gh-148688: Fix _BlocksOutputBuffer_Finish() double free (#148689) · python/cpython@d61fcf8 · GitHub
Skip to content

Commit d61fcf8

Browse files
authored
gh-148688: Fix _BlocksOutputBuffer_Finish() double free (#148689)
If _BlocksOutputBuffer_Finish() fails (memory allocation failure), PyBytesWriter_Discard() is called on the writer. Then if _BlocksOutputBuffer_OnError() is called, it calls again PyBytesWriter_Discard() causing a double free. Fix _BlocksOutputBuffer_Finish() by setting buffer->writer to NULL, so _BlocksOutputBuffer_OnError() does nothing instead of calling PyBytesWriter_Discard() again.
1 parent e9bbf86 commit d61fcf8

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

Include/internal/pycore_blocks_output_buffer.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,12 @@ static inline PyObject *
242242
_BlocksOutputBuffer_Finish(_BlocksOutputBuffer *buffer,
243243
const Py_ssize_t avail_out)
244244
{
245+
PyObject *obj;
245246
assert(buffer->writer != NULL);
246-
return PyBytesWriter_FinishWithSize(buffer->writer,
247-
buffer->allocated - avail_out);
247+
obj = PyBytesWriter_FinishWithSize(buffer->writer,
248+
buffer->allocated - avail_out);
249+
buffer->writer = NULL;
250+
return obj;
248251
}
249252

250253
/* Clean up the buffer when an error occurred. */
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:mod:`bz2`, :mod:`compression.zstd`, :mod:`lzma`, :mod:`zlib`: Fix a double
2+
free on memory allocation failure. Patch by Victor Stinner.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy