[Python-checkins] gh-104372: Use non-Raw malloc for c_fds_to_keep in _posixsubprocess (#104697)
gpshead
webhook-mailer at python.org
Sat May 20 13:09:30 EDT 2023
https://github.com/python/cpython/commit/d1732feea0eadd4ccc3516440d0c071be0093dec
commit: d1732feea0eadd4ccc3516440d0c071be0093dec
branch: main
author: Gregory P. Smith <greg at krypto.org>
committer: gpshead <greg at krypto.org>
date: 2023-05-20T17:09:23Z
summary:
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.
files:
M Modules/_posixsubprocess.c
diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
index 75965d338d59..1b7fe71186a1 100644
--- a/Modules/_posixsubprocess.c
+++ b/Modules/_posixsubprocess.c
@@ -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) {
More information about the Python-checkins
mailing list