From: Felipe Pena Date: Tue, 24 Nov 2009 21:54:12 +0000 (+0000) Subject: - Fixed bug #50255 (isset() and empty() silently casts array to object) X-Git-Tag: php-5.3.2RC1~190 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bb179ad150fdebfcc1128e0b25a132695dd39f92;p=php - Fixed bug #50255 (isset() and empty() silently casts array to object) --- diff --git a/NEWS b/NEWS index 15f2e0b1d1..bf2f24bbf2 100644 --- a/NEWS +++ b/NEWS @@ -29,6 +29,8 @@ PHP NEWS - Fixed bug #50282 (xmlrpc_encode_request() changes object into array in calling function). (Felipe) - Fixed bug #50267 (get_browser(null) does not use HTTP_USER_AGENT). (Jani) +- Fixed bug #50255 (isset() and empty() silently casts array to object). + (Felipe) - Fixed bug #50240 (pdo_mysql.default_socket in php.ini shouldn't used if it is empty). (foutrelis at gmail dot com, Ilia) - Fixed bug #50219 (soap call Segmentation fault on a redirected url). 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 621fecde07..52f200e35d 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -3915,7 +3915,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 e6fd0d314f..38bd50be16 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -10806,7 +10806,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; @@ -12555,7 +12555,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; @@ -14355,7 +14355,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; @@ -16741,7 +16741,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; @@ -17931,7 +17931,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; @@ -18988,7 +18988,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; @@ -20045,7 +20045,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; @@ -21361,7 +21361,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; @@ -24347,7 +24347,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; @@ -25987,7 +25987,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; @@ -27677,7 +27677,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; @@ -29854,7 +29854,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;