Skip to content

Commit e903818

Browse files
committed
Simplify code for finding descriptor to redirect to
1 parent a30aa5a commit e903818

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

ext/standard/proc_open.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -870,8 +870,7 @@ PHP_FUNCTION(proc_open)
870870
}
871871
} else if (strcmp(Z_STRVAL_P(ztype), "redirect") == 0) {
872872
zval *ztarget = zend_hash_index_find_deref(Z_ARRVAL_P(descitem), 1);
873-
struct php_proc_open_descriptor_item *target = NULL;
874-
php_file_descriptor_t childend;
873+
php_file_descriptor_t childend = -1;
875874

876875
if (!ztarget) {
877876
zend_value_error("Missing redirection target");
@@ -884,13 +883,12 @@ PHP_FUNCTION(proc_open)
884883

885884
for (i = 0; i < ndesc; i++) {
886885
if (descriptors[i].index == Z_LVAL_P(ztarget)) {
887-
target = &descriptors[i];
886+
childend = descriptors[i].childend;
888887
break;
889888
}
890889
}
891-
if (target) {
892-
childend = target->childend;
893-
} else {
890+
891+
if (childend == -1) {
894892
if (Z_LVAL_P(ztarget) < 0 || Z_LVAL_P(ztarget) > 2) {
895893
php_error_docref(NULL, E_WARNING,
896894
"Redirection target " ZEND_LONG_FMT " not found", Z_LVAL_P(ztarget));

0 commit comments

Comments
 (0)