https://github.com/python/cpython/commit/54362898f32bf195db898bfead15784d6ab5831b
commit: 54362898f32bf195db898bfead15784d6ab5831b
branch: main
author: Pablo Galindo Salgado <[email protected]>
committer: pablogsal <[email protected]>
date: 2025-12-27T01:39:21Z
summary:

gh-140739: Fix missing exception on allocation failure in BinaryWriter (#143204)

files:
M Modules/_remote_debugging/binary_io_writer.c

diff --git a/Modules/_remote_debugging/binary_io_writer.c 
b/Modules/_remote_debugging/binary_io_writer.c
index c8857cec6218be..c129c93efe23c5 100644
--- a/Modules/_remote_debugging/binary_io_writer.c
+++ b/Modules/_remote_debugging/binary_io_writer.c
@@ -741,6 +741,7 @@ binary_writer_create(const char *filename, uint64_t 
sample_interval_us, int comp
 
     writer->write_buffer = PyMem_Malloc(WRITE_BUFFER_SIZE);
     if (!writer->write_buffer) {
+        PyErr_NoMemory();
         goto error;
     }
     writer->buffer_size = WRITE_BUFFER_SIZE;
@@ -753,14 +754,17 @@ binary_writer_create(const char *filename, uint64_t 
sample_interval_us, int comp
         NULL                 /* Use default allocator */
     );
     if (!writer->string_hash) {
+        PyErr_NoMemory();
         goto error;
     }
     writer->strings = PyMem_Malloc(INITIAL_STRING_CAPACITY * sizeof(char *));
     if (!writer->strings) {
+        PyErr_NoMemory();
         goto error;
     }
     writer->string_lengths = PyMem_Malloc(INITIAL_STRING_CAPACITY * 
sizeof(size_t));
     if (!writer->string_lengths) {
+        PyErr_NoMemory();
         goto error;
     }
     writer->string_capacity = INITIAL_STRING_CAPACITY;
@@ -773,16 +777,19 @@ binary_writer_create(const char *filename, uint64_t 
sample_interval_us, int comp
         NULL                 /* Use default allocator */
     );
     if (!writer->frame_hash) {
+        PyErr_NoMemory();
         goto error;
     }
     writer->frame_entries = PyMem_Malloc(INITIAL_FRAME_CAPACITY * 
sizeof(FrameEntry));
     if (!writer->frame_entries) {
+        PyErr_NoMemory();
         goto error;
     }
     writer->frame_capacity = INITIAL_FRAME_CAPACITY;
 
     writer->thread_entries = PyMem_Malloc(INITIAL_THREAD_CAPACITY * 
sizeof(ThreadEntry));
     if (!writer->thread_entries) {
+        PyErr_NoMemory();
         goto error;
     }
     writer->thread_capacity = INITIAL_THREAD_CAPACITY;

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to