Skip to content

Commit c1b9088

Browse files
committed
Replace deprecated conditions by ZEND_ASSERT.
1 parent 290e520 commit c1b9088

File tree

2 files changed

+296
-218
lines changed

2 files changed

+296
-218
lines changed

Zend/zend_vm_def.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4355,8 +4355,8 @@ ZEND_VM_COLD_CONST_HANDLER(111, ZEND_RETURN_BY_REF, CONST|TMP|VAR|CV, ANY, SRC)
43554355
retval_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W);
43564356

43574357
if (OP1_TYPE == IS_VAR) {
4358-
if (retval_ptr == &EG(uninitialized_zval) ||
4359-
(opline->extended_value == ZEND_RETURNS_FUNCTION && !Z_ISREF_P(retval_ptr))) {
4358+
ZEND_ASSERT(retval_ptr != &EG(uninitialized_zval));
4359+
if (opline->extended_value == ZEND_RETURNS_FUNCTION && !Z_ISREF_P(retval_ptr)) {
43604360
zend_error(E_NOTICE, "Only variable references should be returned by reference");
43614361
if (EX(return_value)) {
43624362
ZVAL_NEW_REF(EX(return_value), retval_ptr);
@@ -7621,20 +7621,23 @@ ZEND_VM_HANDLER(160, ZEND_YIELD, CONST|TMP|VAR|CV|UNUSED, CONST|TMP|VAR|CV|UNUSE
76217621

76227622
/* If a function call result is yielded and the function did
76237623
* not return by reference we throw a notice. */
7624-
if (OP1_TYPE == IS_VAR &&
7625-
(value_ptr == &EG(uninitialized_zval) ||
7626-
(opline->extended_value == ZEND_RETURNS_FUNCTION &&
7627-
!Z_ISREF_P(value_ptr)))) {
7628-
zend_error(E_NOTICE, "Only variable references should be yielded by reference");
7629-
ZVAL_COPY(&generator->value, value_ptr);
7630-
} else {
7624+
do {
7625+
if (OP1_TYPE == IS_VAR) {
7626+
ZEND_ASSERT(value_ptr != &EG(uninitialized_zval));
7627+
if (opline->extended_value == ZEND_RETURNS_FUNCTION
7628+
&& !Z_ISREF_P(value_ptr)) {
7629+
zend_error(E_NOTICE, "Only variable references should be yielded by reference");
7630+
ZVAL_COPY(&generator->value, value_ptr);
7631+
break;
7632+
}
7633+
}
76317634
if (Z_ISREF_P(value_ptr)) {
76327635
Z_ADDREF_P(value_ptr);
76337636
} else {
76347637
ZVAL_MAKE_REF_EX(value_ptr, 2);
76357638
}
76367639
ZVAL_REF(&generator->value, Z_REF_P(value_ptr));
7637-
}
7640+
} while (0);
76387641

76397642
FREE_OP1_VAR_PTR();
76407643
}

0 commit comments

Comments
 (0)