Skip to content

Commit b5517cd

Browse files
Fix build errors from incorrect type passed to PyMem_New
1 parent 5b628ab commit b5517cd

3 files changed

Lines changed: 3 additions & 2 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix overflow vulnerabilities in PyMem_Malloc calls by systematically replacing them with PyMem_New or adding explicit PY_SSIZE_T_MAX checks.

Modules/_zoneinfo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ load_data(zoneinfo_state *state, PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
10471047
PyErr_NoMemory();
10481048
goto error;
10491049
}
1050-
trans_idx = PyMem_New(Py_ssize_t, self->num_transitions);
1050+
trans_idx = PyMem_New(size_t, self->num_transitions);
10511051
if (trans_idx == NULL) {
10521052
PyErr_NoMemory();
10531053
goto error;

Python/instrumentation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1779,7 +1779,7 @@ update_instrumentation_data(PyCodeObject *code, PyInterpreterState *interp)
17791779
}
17801780
if (all_events.tools[PY_MONITORING_EVENT_INSTRUCTION]) {
17811781
if (code->_co_monitoring->per_instruction_opcodes == NULL) {
1782-
code->_co_monitoring->per_instruction_opcodes = PyMem_New(_PyCoLineInstrumentationData, code_len);
1782+
code->_co_monitoring->per_instruction_opcodes = PyMem_New(uint8_t, code_len);
17831783
if (code->_co_monitoring->per_instruction_opcodes == NULL) {
17841784
PyErr_NoMemory();
17851785
return -1;

0 commit comments

Comments
 (0)