Skip to content

Commit 5436289

Browse files
authored
gh-140739: Fix missing exception on allocation failure in BinaryWriter (#143204)
1 parent 9d92ac1 commit 5436289

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Modules/_remote_debugging/binary_io_writer.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,7 @@ binary_writer_create(const char *filename, uint64_t sample_interval_us, int comp
741741

742742
writer->write_buffer = PyMem_Malloc(WRITE_BUFFER_SIZE);
743743
if (!writer->write_buffer) {
744+
PyErr_NoMemory();
744745
goto error;
745746
}
746747
writer->buffer_size = WRITE_BUFFER_SIZE;
@@ -753,14 +754,17 @@ binary_writer_create(const char *filename, uint64_t sample_interval_us, int comp
753754
NULL /* Use default allocator */
754755
);
755756
if (!writer->string_hash) {
757+
PyErr_NoMemory();
756758
goto error;
757759
}
758760
writer->strings = PyMem_Malloc(INITIAL_STRING_CAPACITY * sizeof(char *));
759761
if (!writer->strings) {
762+
PyErr_NoMemory();
760763
goto error;
761764
}
762765
writer->string_lengths = PyMem_Malloc(INITIAL_STRING_CAPACITY * sizeof(size_t));
763766
if (!writer->string_lengths) {
767+
PyErr_NoMemory();
764768
goto error;
765769
}
766770
writer->string_capacity = INITIAL_STRING_CAPACITY;
@@ -773,16 +777,19 @@ binary_writer_create(const char *filename, uint64_t sample_interval_us, int comp
773777
NULL /* Use default allocator */
774778
);
775779
if (!writer->frame_hash) {
780+
PyErr_NoMemory();
776781
goto error;
777782
}
778783
writer->frame_entries = PyMem_Malloc(INITIAL_FRAME_CAPACITY * sizeof(FrameEntry));
779784
if (!writer->frame_entries) {
785+
PyErr_NoMemory();
780786
goto error;
781787
}
782788
writer->frame_capacity = INITIAL_FRAME_CAPACITY;
783789

784790
writer->thread_entries = PyMem_Malloc(INITIAL_THREAD_CAPACITY * sizeof(ThreadEntry));
785791
if (!writer->thread_entries) {
792+
PyErr_NoMemory();
786793
goto error;
787794
}
788795
writer->thread_capacity = INITIAL_THREAD_CAPACITY;

0 commit comments

Comments
 (0)