Skip to content

Commit 78ea6d5

Browse files
committed
Move _file_actions to outer scope to avoid undefined behaviour
1 parent 57b6303 commit 78ea6d5

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

Modules/posixmodule.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5140,6 +5140,7 @@ os_posix_spawn_impl(PyObject *module, path_t *path, PyObject *argv,
51405140
{
51415141
EXECV_CHAR **argvlist = NULL;
51425142
EXECV_CHAR **envlist = NULL;
5143+
posix_spawn_file_actions_t _file_actions;
51435144
posix_spawn_file_actions_t *file_actionsp = NULL;
51445145
Py_ssize_t argc, envc;
51455146
PyObject* result = NULL;
@@ -5183,17 +5184,14 @@ os_posix_spawn_impl(PyObject *module, path_t *path, PyObject *argv,
51835184

51845185
pid_t pid;
51855186
if (file_actions != NULL && file_actions != Py_None){
5186-
posix_spawn_file_actions_t _file_actions;
51875187
if(posix_spawn_file_actions_init(&_file_actions) != 0){
51885188
PyErr_SetString(PyExc_OSError,
51895189
"Error initializing file actions");
51905190
goto exit;
51915191
}
51925192

5193-
51945193
file_actionsp = &_file_actions;
51955194

5196-
51975195
seq = PySequence_Fast(file_actions, "file_actions must be a sequence");
51985196
if(seq == NULL){
51995197
goto exit;

0 commit comments

Comments
 (0)