Skip to content

Commit 0d7f203

Browse files
committed
Add ref to command_str and always release it
1 parent 0ba3a6f commit 0d7f203

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

ext/standard/proc_open.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,15 +1060,18 @@ PHP_FUNCTION(proc_open)
10601060
/* Automatically bypass shell if command is given as an array */
10611061
bypass_shell = 1;
10621062
command_str = create_win_command_from_args(command_ht);
1063-
if (!command_str) {
1064-
RETURN_FALSE;
1065-
}
10661063
#else
10671064
command_str = get_command_from_array(command_ht, &argv, num_elems);
1065+
#endif
1066+
10681067
if (!command_str) {
1069-
goto exit_fail;
1070-
}
1068+
#ifndef PHP_WIN32
1069+
efree_argv(argv);
10711070
#endif
1071+
RETURN_FALSE;
1072+
}
1073+
} else {
1074+
zend_string_addref(command_str);
10721075
}
10731076

10741077
#ifdef PHP_WIN32
@@ -1311,11 +1314,7 @@ PHP_FUNCTION(proc_open)
13111314
RETVAL_FALSE;
13121315
}
13131316

1314-
/* the command_str needs to be freed if it was created by parsing an array */
1315-
if (command_ht && command_str) {
1316-
zend_string_release_ex(command_str, false);
1317-
}
1318-
1317+
zend_string_release_ex(command_str, false);
13191318
#ifdef PHP_WIN32
13201319
free(cwdw);
13211320
free(cmdw);

0 commit comments

Comments
 (0)