Skip to content

Commit d1732fe

Browse files
authored
gh-104372: Use non-Raw malloc for c_fds_to_keep in _posixsubprocess (#104697)
Use non-Raw malloc for c_fds_to_keep as the code could ask for 0 length.
1 parent 68ee8b3 commit d1732fe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Modules/_posixsubprocess.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ subprocess_fork_exec_impl(PyObject *module, PyObject *process_args,
10741074
#endif /* HAVE_SETREUID */
10751075
}
10761076

1077-
c_fds_to_keep = PyMem_RawMalloc(fds_to_keep_len * sizeof(int));
1077+
c_fds_to_keep = PyMem_Malloc(fds_to_keep_len * sizeof(int));
10781078
if (c_fds_to_keep == NULL) {
10791079
PyErr_SetString(PyExc_MemoryError, "failed to malloc c_fds_to_keep");
10801080
goto cleanup;
@@ -1157,7 +1157,7 @@ subprocess_fork_exec_impl(PyObject *module, PyObject *process_args,
11571157

11581158
cleanup:
11591159
if (c_fds_to_keep != NULL) {
1160-
PyMem_RawFree(c_fds_to_keep);
1160+
PyMem_Free(c_fds_to_keep);
11611161
}
11621162

11631163
if (saved_errno != 0) {

0 commit comments

Comments
 (0)