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.
This commit is contained in:
Gregory P. Smith 2023-05-20 10:09:23 -07:00 committed by GitHub
parent 68ee8b3f15
commit d1732feea0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -1074,7 +1074,7 @@ subprocess_fork_exec_impl(PyObject *module, PyObject *process_args,
#endif /* HAVE_SETREUID */
}
c_fds_to_keep = PyMem_RawMalloc(fds_to_keep_len * sizeof(int));
c_fds_to_keep = PyMem_Malloc(fds_to_keep_len * sizeof(int));
if (c_fds_to_keep == NULL) {
PyErr_SetString(PyExc_MemoryError, "failed to malloc c_fds_to_keep");
goto cleanup;
@ -1157,7 +1157,7 @@ subprocess_fork_exec_impl(PyObject *module, PyObject *process_args,
cleanup:
if (c_fds_to_keep != NULL) {
PyMem_RawFree(c_fds_to_keep);
PyMem_Free(c_fds_to_keep);
}
if (saved_errno != 0) {