Skip to content

Commit 6c91aec

Browse files
committed
Simplify code for finding descriptor to redirect to
1 parent 3dabfa9 commit 6c91aec

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
@@ -869,8 +869,7 @@ PHP_FUNCTION(proc_open)
869869
}
870870
} else if (strcmp(Z_STRVAL_P(ztype), "redirect") == 0) {
871871
zval *ztarget = zend_hash_index_find_deref(Z_ARRVAL_P(descitem), 1);
872-
struct php_proc_open_descriptor_item *target = NULL;
873-
php_file_descriptor_t childend;
872+
php_file_descriptor_t childend = -1;
874873

875874
if (!ztarget) {
876875
zend_value_error("Missing redirection target");
@@ -883,13 +882,12 @@ PHP_FUNCTION(proc_open)
883882

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

0 commit comments

Comments
 (0)