Skip to content

Commit d94a3fb

Browse files
Fix build errors from incorrect type passed to PyMem_New
1 parent 7aac63a commit d94a3fb

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
@@ -1784,7 +1784,7 @@ update_instrumentation_data(PyCodeObject *code, PyInterpreterState *interp)
17841784
}
17851785
if (all_events.tools[PY_MONITORING_EVENT_INSTRUCTION]) {
17861786
if (code->_co_monitoring->per_instruction_opcodes == NULL) {
1787-
code->_co_monitoring->per_instruction_opcodes = PyMem_New(_PyCoLineInstrumentationData, code_len);
1787+
code->_co_monitoring->per_instruction_opcodes = PyMem_New(uint8_t, code_len);
17881788
if (code->_co_monitoring->per_instruction_opcodes == NULL) {
17891789
PyErr_NoMemory();
17901790
return -1;

0 commit comments

Comments
 (0)