Skip to content

Commit b6b359b

Browse files
committed
Add ref to command_str and always release it
1 parent cfe8b2c commit b6b359b

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
@@ -1056,15 +1056,18 @@ PHP_FUNCTION(proc_open)
10561056
/* Automatically bypass shell if command is given as an array */
10571057
bypass_shell = 1;
10581058
command_str = create_win_command_from_args(command_ht);
1059-
if (!command_str) {
1060-
RETURN_FALSE;
1061-
}
10621059
#else
10631060
command_str = get_command_from_array(command_ht, &argv, num_elems);
1061+
#endif
1062+
10641063
if (!command_str) {
1065-
goto exit_fail;
1066-
}
1064+
#ifndef PHP_WIN32
1065+
efree_argv(argv);
10671066
#endif
1067+
RETURN_FALSE;
1068+
}
1069+
} else {
1070+
zend_string_addref(command_str);
10681071
}
10691072

10701073
#ifdef PHP_WIN32
@@ -1307,11 +1310,7 @@ PHP_FUNCTION(proc_open)
13071310
RETVAL_FALSE;
13081311
}
13091312

1310-
/* the command_str needs to be freed if it was created by parsing an array */
1311-
if (command_ht && command_str) {
1312-
zend_string_release_ex(command_str, false);
1313-
}
1314-
1313+
zend_string_release_ex(command_str, false);
13151314
#ifdef PHP_WIN32
13161315
free(cwdw);
13171316
free(cmdw);

0 commit comments

Comments
 (0)