From 1d71e14007c7969dafca6da23b440a5c2b376f39 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Tue, 24 Nov 2009 21:54:12 +0000 Subject: [PATCH] - Fixed bug #50255 (isset() and empty() silently casts array to object) --- Zend/tests/bug50255.phpt | 30 ++++++++++++++++++++++++++++++ Zend/zend_vm_def.h | 2 +- Zend/zend_vm_execute.h | 24 ++++++++++++------------ 3 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 Zend/tests/bug50255.phpt diff --git a/Zend/tests/bug50255.phpt b/Zend/tests/bug50255.phpt new file mode 100644 index 0000000000..9f390af7cf --- /dev/null +++ b/Zend/tests/bug50255.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #50255 (isset() and empty() silently casts array to object) +--FILE-- + 'bar'); + +print "isset\n"; +var_dump(isset($arr->foo)); +var_dump(isset($arr->bar)); +var_dump(isset($arr['foo'])); +var_dump(isset($arr['bar'])); +print "empty\n"; +var_dump(empty($arr->foo)); +var_dump(empty($arr->bar)); +var_dump(empty($arr['foo'])); +var_dump(empty($arr['bar'])); + +?> +--EXPECT-- +isset +bool(false) +bool(false) +bool(true) +bool(false) +empty +bool(true) +bool(true) +bool(false) +bool(true) diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index cbeffa4df6..5a3020d616 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -4095,7 +4095,7 @@ ZEND_VM_HELPER_EX(zend_isset_isempty_dim_prop_obj_handler, VAR|UNUSED|CV, CONST| zend_free_op free_op2; zval *offset = GET_OP2_ZVAL_PTR(BP_VAR_R); - if (Z_TYPE_PP(container) == IS_ARRAY) { + if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; int isset = 0; diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index f1b16ccdd5..c90a479287 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -11279,7 +11279,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_VAR_CONST( zval *offset = &opline->op2.u.constant; - if (Z_TYPE_PP(container) == IS_ARRAY) { + if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; int isset = 0; @@ -13097,7 +13097,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_VAR_TMP(in zend_free_op free_op2; zval *offset = _get_zval_ptr_tmp(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC); - if (Z_TYPE_PP(container) == IS_ARRAY) { + if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; int isset = 0; @@ -14966,7 +14966,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_VAR_VAR(in zend_free_op free_op2; zval *offset = _get_zval_ptr_var(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC); - if (Z_TYPE_PP(container) == IS_ARRAY) { + if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; int isset = 0; @@ -17428,7 +17428,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_VAR_CV(int zval *offset = _get_zval_ptr_cv(&opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC); - if (Z_TYPE_PP(container) == IS_ARRAY) { + if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; int isset = 0; @@ -18684,7 +18684,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_UNUSED_CON zval *offset = &opline->op2.u.constant; - if (Z_TYPE_PP(container) == IS_ARRAY) { + if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; int isset = 0; @@ -19799,7 +19799,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_UNUSED_TMP zend_free_op free_op2; zval *offset = _get_zval_ptr_tmp(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC); - if (Z_TYPE_PP(container) == IS_ARRAY) { + if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; int isset = 0; @@ -20914,7 +20914,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_UNUSED_VAR zend_free_op free_op2; zval *offset = _get_zval_ptr_var(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC); - if (Z_TYPE_PP(container) == IS_ARRAY) { + if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; int isset = 0; @@ -22287,7 +22287,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_UNUSED_CV( zval *offset = _get_zval_ptr_cv(&opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC); - if (Z_TYPE_PP(container) == IS_ARRAY) { + if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; int isset = 0; @@ -25482,7 +25482,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_CV_CONST(i zval *offset = &opline->op2.u.constant; - if (Z_TYPE_PP(container) == IS_ARRAY) { + if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; int isset = 0; @@ -27188,7 +27188,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_CV_TMP(int zend_free_op free_op2; zval *offset = _get_zval_ptr_tmp(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC); - if (Z_TYPE_PP(container) == IS_ARRAY) { + if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; int isset = 0; @@ -28944,7 +28944,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_CV_VAR(int zend_free_op free_op2; zval *offset = _get_zval_ptr_var(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC); - if (Z_TYPE_PP(container) == IS_ARRAY) { + if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; int isset = 0; @@ -31191,7 +31191,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_CV_CV(int zval *offset = _get_zval_ptr_cv(&opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC); - if (Z_TYPE_PP(container) == IS_ARRAY) { + if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; int isset = 0; -- 2.50.1