diff options
| author | Tyson Andre <tysonandre775@hotmail.com> | 2019-11-15 12:47:32 -0500 |
|---|---|---|
| committer | Dmitry Stogov <dmitry@zend.com> | 2019-11-18 11:24:03 +0300 |
| commit | a2c41c0ea6e6b6afbfaaeae25e66fd17e746a98a (patch) | |
| tree | 3d599b8e163bc0596555a4a7b6b8ffbc5126b234 /Zend/zend_vm_def.h | |
| parent | 2c9926f156b2be6aa4f69a169d028c1ebc1eaa34 (diff) | |
| download | php-git-a2c41c0ea6e6b6afbfaaeae25e66fd17e746a98a.tar.gz | |
Fix $x = (bool)$x; for undefined with opcache
And `$x = !$x`
Noticed while working on GH-4912
The included test would not emit undefined variable errors in php 8.0
with opcache enabled. The command used:
```
php -d zend_extension=opcache.so --no-php-ini -d error_reporting=E_ALL \
-d opcache.file_cache= -d opcache.enable_cli=1 test.php
```
Diffstat (limited to 'Zend/zend_vm_def.h')
| -rw-r--r-- | Zend/zend_vm_def.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index e4431e6a3a..ed84d17bb8 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -758,8 +758,10 @@ ZEND_VM_HANDLER(13, ZEND_BOOL_NOT, CONST|TMPVAR|CV, ANY) if (Z_TYPE_INFO_P(val) == IS_TRUE) { ZVAL_FALSE(EX_VAR(opline->result.var)); } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) { + /* The result and op1 can be the same cv zval */ + const uint32_t orig_val_type = Z_TYPE_INFO_P(val); ZVAL_TRUE(EX_VAR(opline->result.var)); - if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) { + if (OP1_TYPE == IS_CV && UNEXPECTED(orig_val_type == IS_UNDEF)) { SAVE_OPLINE(); GET_OP1_UNDEF_CV(val, BP_VAR_R); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); @@ -4755,8 +4757,10 @@ ZEND_VM_HANDLER(52, ZEND_BOOL, CONST|TMPVAR|CV, ANY) if (Z_TYPE_INFO_P(val) == IS_TRUE) { ZVAL_TRUE(EX_VAR(opline->result.var)); } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) { + /* The result and op1 can be the same cv zval */ + const uint32_t orig_val_type = Z_TYPE_INFO_P(val); ZVAL_FALSE(EX_VAR(opline->result.var)); - if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) { + if (OP1_TYPE == IS_CV && UNEXPECTED(orig_val_type == IS_UNDEF)) { SAVE_OPLINE(); GET_OP1_UNDEF_CV(val, BP_VAR_R); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); |
