Commit c65d0f6
committed
gh-140739: Fix missing exception on allocation failure in BinaryWriter
The binary_writer_create function had several error paths where memory
allocation failures would return NULL without setting a Python exception.
This violated the C API contract and caused "returning an error without
exception set" errors when BinaryWriter initialization failed due to
memory pressure.
Added PyErr_NoMemory calls before each goto error for PyMem_Malloc and
_Py_hashtable_new_full failures. Neither of these functions set exceptions
on failure, so callers must do it explicitly. The error label only performs
cleanup and returns NULL, relying on exceptions being set beforehand.1 parent 9d92ac1 commit c65d0f6
1 file changed
+7
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
741 | 741 | | |
742 | 742 | | |
743 | 743 | | |
| 744 | + | |
744 | 745 | | |
745 | 746 | | |
746 | 747 | | |
| |||
753 | 754 | | |
754 | 755 | | |
755 | 756 | | |
| 757 | + | |
756 | 758 | | |
757 | 759 | | |
758 | 760 | | |
759 | 761 | | |
| 762 | + | |
760 | 763 | | |
761 | 764 | | |
762 | 765 | | |
763 | 766 | | |
| 767 | + | |
764 | 768 | | |
765 | 769 | | |
766 | 770 | | |
| |||
773 | 777 | | |
774 | 778 | | |
775 | 779 | | |
| 780 | + | |
776 | 781 | | |
777 | 782 | | |
778 | 783 | | |
779 | 784 | | |
| 785 | + | |
780 | 786 | | |
781 | 787 | | |
782 | 788 | | |
783 | 789 | | |
784 | 790 | | |
785 | 791 | | |
| 792 | + | |
786 | 793 | | |
787 | 794 | | |
788 | 795 | | |
| |||
0 commit comments