summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-09-27 10:39:21 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-09-27 10:40:41 +0200
commita6c9c7c2b8cfd4db8fcdcb66b908feac31b600af (patch)
treeaa58af21678aa7da13c6c100fbe77f2055df2bb9 /Zend
parentd71f859a56757df16e20d72b22366a02ff9fec54 (diff)
downloadphp-git-a6c9c7c2b8cfd4db8fcdcb66b908feac31b600af.tar.gz
Handle resources used as array keys consistently
Resources used as array keys are generally handled by throwing a notice and converting the resource to the resource handle. The only exception is the [$resource => null] syntax, where this was treated as an illegal offset type instead. However, this also only happened for VM evaluations, the AST evaluator did handle resources correctly.
Diffstat (limited to 'Zend')
-rw-r--r--Zend/zend_vm_def.h4
-rw-r--r--Zend/zend_vm_execute.h64
2 files changed, 68 insertions, 0 deletions
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 823f5398b2..7c102073a3 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -5717,6 +5717,10 @@ ZEND_VM_C_LABEL(num_index):
} else if (Z_TYPE_P(offset) == IS_TRUE) {
hval = 1;
ZEND_VM_C_GOTO(num_index);
+ } else if (Z_TYPE_P(offset) == IS_RESOURCE) {
+ zend_use_resource_as_offset(offset);
+ hval = Z_RES_HANDLE_P(offset);
+ ZEND_VM_C_GOTO(num_index);
} else if (OP2_TYPE == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) {
ZVAL_UNDEFINED_OP2();
str = ZSTR_EMPTY_ALLOC();
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 81b6c3d8e6..4cd21c0e61 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -6169,6 +6169,10 @@ num_index:
} else if (Z_TYPE_P(offset) == IS_TRUE) {
hval = 1;
goto num_index;
+ } else if (Z_TYPE_P(offset) == IS_RESOURCE) {
+ zend_use_resource_as_offset(offset);
+ hval = Z_RES_HANDLE_P(offset);
+ goto num_index;
} else if (IS_CONST == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) {
ZVAL_UNDEFINED_OP2();
str = ZSTR_EMPTY_ALLOC();
@@ -8356,6 +8360,10 @@ num_index:
} else if (Z_TYPE_P(offset) == IS_TRUE) {
hval = 1;
goto num_index;
+ } else if (Z_TYPE_P(offset) == IS_RESOURCE) {
+ zend_use_resource_as_offset(offset);
+ hval = Z_RES_HANDLE_P(offset);
+ goto num_index;
} else if ((IS_TMP_VAR|IS_VAR) == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) {
ZVAL_UNDEFINED_OP2();
str = ZSTR_EMPTY_ALLOC();
@@ -9315,6 +9323,10 @@ num_index:
} else if (Z_TYPE_P(offset) == IS_TRUE) {
hval = 1;
goto num_index;
+ } else if (Z_TYPE_P(offset) == IS_RESOURCE) {
+ zend_use_resource_as_offset(offset);
+ hval = Z_RES_HANDLE_P(offset);
+ goto num_index;
} else if (IS_UNUSED == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) {
ZVAL_UNDEFINED_OP2();
str = ZSTR_EMPTY_ALLOC();
@@ -10799,6 +10811,10 @@ num_index:
} else if (Z_TYPE_P(offset) == IS_TRUE) {
hval = 1;
goto num_index;
+ } else if (Z_TYPE_P(offset) == IS_RESOURCE) {
+ zend_use_resource_as_offset(offset);
+ hval = Z_RES_HANDLE_P(offset);
+ goto num_index;
} else if (IS_CV == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) {
ZVAL_UNDEFINED_OP2();
str = ZSTR_EMPTY_ALLOC();
@@ -18744,6 +18760,10 @@ num_index:
} else if (Z_TYPE_P(offset) == IS_TRUE) {
hval = 1;
goto num_index;
+ } else if (Z_TYPE_P(offset) == IS_RESOURCE) {
+ zend_use_resource_as_offset(offset);
+ hval = Z_RES_HANDLE_P(offset);
+ goto num_index;
} else if (IS_CONST == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) {
ZVAL_UNDEFINED_OP2();
str = ZSTR_EMPTY_ALLOC();
@@ -19168,6 +19188,10 @@ num_index:
} else if (Z_TYPE_P(offset) == IS_TRUE) {
hval = 1;
goto num_index;
+ } else if (Z_TYPE_P(offset) == IS_RESOURCE) {
+ zend_use_resource_as_offset(offset);
+ hval = Z_RES_HANDLE_P(offset);
+ goto num_index;
} else if ((IS_TMP_VAR|IS_VAR) == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) {
ZVAL_UNDEFINED_OP2();
str = ZSTR_EMPTY_ALLOC();
@@ -19668,6 +19692,10 @@ num_index:
} else if (Z_TYPE_P(offset) == IS_TRUE) {
hval = 1;
goto num_index;
+ } else if (Z_TYPE_P(offset) == IS_RESOURCE) {
+ zend_use_resource_as_offset(offset);
+ hval = Z_RES_HANDLE_P(offset);
+ goto num_index;
} else if (IS_UNUSED == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) {
ZVAL_UNDEFINED_OP2();
str = ZSTR_EMPTY_ALLOC();
@@ -20071,6 +20099,10 @@ num_index:
} else if (Z_TYPE_P(offset) == IS_TRUE) {
hval = 1;
goto num_index;
+ } else if (Z_TYPE_P(offset) == IS_RESOURCE) {
+ zend_use_resource_as_offset(offset);
+ hval = Z_RES_HANDLE_P(offset);
+ goto num_index;
} else if (IS_CV == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) {
ZVAL_UNDEFINED_OP2();
str = ZSTR_EMPTY_ALLOC();
@@ -23897,6 +23929,10 @@ num_index:
} else if (Z_TYPE_P(offset) == IS_TRUE) {
hval = 1;
goto num_index;
+ } else if (Z_TYPE_P(offset) == IS_RESOURCE) {
+ zend_use_resource_as_offset(offset);
+ hval = Z_RES_HANDLE_P(offset);
+ goto num_index;
} else if (IS_CONST == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) {
ZVAL_UNDEFINED_OP2();
str = ZSTR_EMPTY_ALLOC();
@@ -26043,6 +26079,10 @@ num_index:
} else if (Z_TYPE_P(offset) == IS_TRUE) {
hval = 1;
goto num_index;
+ } else if (Z_TYPE_P(offset) == IS_RESOURCE) {
+ zend_use_resource_as_offset(offset);
+ hval = Z_RES_HANDLE_P(offset);
+ goto num_index;
} else if ((IS_TMP_VAR|IS_VAR) == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) {
ZVAL_UNDEFINED_OP2();
str = ZSTR_EMPTY_ALLOC();
@@ -27656,6 +27696,10 @@ num_index:
} else if (Z_TYPE_P(offset) == IS_TRUE) {
hval = 1;
goto num_index;
+ } else if (Z_TYPE_P(offset) == IS_RESOURCE) {
+ zend_use_resource_as_offset(offset);
+ hval = Z_RES_HANDLE_P(offset);
+ goto num_index;
} else if (IS_UNUSED == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) {
ZVAL_UNDEFINED_OP2();
str = ZSTR_EMPTY_ALLOC();
@@ -29793,6 +29837,10 @@ num_index:
} else if (Z_TYPE_P(offset) == IS_TRUE) {
hval = 1;
goto num_index;
+ } else if (Z_TYPE_P(offset) == IS_RESOURCE) {
+ zend_use_resource_as_offset(offset);
+ hval = Z_RES_HANDLE_P(offset);
+ goto num_index;
} else if (IS_CV == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) {
ZVAL_UNDEFINED_OP2();
str = ZSTR_EMPTY_ALLOC();
@@ -40974,6 +41022,10 @@ num_index:
} else if (Z_TYPE_P(offset) == IS_TRUE) {
hval = 1;
goto num_index;
+ } else if (Z_TYPE_P(offset) == IS_RESOURCE) {
+ zend_use_resource_as_offset(offset);
+ hval = Z_RES_HANDLE_P(offset);
+ goto num_index;
} else if (IS_CONST == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) {
ZVAL_UNDEFINED_OP2();
str = ZSTR_EMPTY_ALLOC();
@@ -44396,6 +44448,10 @@ num_index:
} else if (Z_TYPE_P(offset) == IS_TRUE) {
hval = 1;
goto num_index;
+ } else if (Z_TYPE_P(offset) == IS_RESOURCE) {
+ zend_use_resource_as_offset(offset);
+ hval = Z_RES_HANDLE_P(offset);
+ goto num_index;
} else if ((IS_TMP_VAR|IS_VAR) == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) {
ZVAL_UNDEFINED_OP2();
str = ZSTR_EMPTY_ALLOC();
@@ -46129,6 +46185,10 @@ num_index:
} else if (Z_TYPE_P(offset) == IS_TRUE) {
hval = 1;
goto num_index;
+ } else if (Z_TYPE_P(offset) == IS_RESOURCE) {
+ zend_use_resource_as_offset(offset);
+ hval = Z_RES_HANDLE_P(offset);
+ goto num_index;
} else if (IS_UNUSED == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) {
ZVAL_UNDEFINED_OP2();
str = ZSTR_EMPTY_ALLOC();
@@ -49553,6 +49613,10 @@ num_index:
} else if (Z_TYPE_P(offset) == IS_TRUE) {
hval = 1;
goto num_index;
+ } else if (Z_TYPE_P(offset) == IS_RESOURCE) {
+ zend_use_resource_as_offset(offset);
+ hval = Z_RES_HANDLE_P(offset);
+ goto num_index;
} else if (IS_CV == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) {
ZVAL_UNDEFINED_OP2();
str = ZSTR_EMPTY_ALLOC();