ID:               31098
 Comment by:       jkkn at jkkn dot dk
 Reported By:      jyounger at caedic dot com
 Status:           Open
 Bug Type:         Zend Engine 2 problem
 Operating System: Slackare Linux Kernel 2.4.26
 PHP Version:      5.0.3
 New Comment:

At time patching for bug #2 9883, 'dmitry'not only applied the patch,
but also added autocasting for the offset, therefore:
isset($simpleString['nonExistentStringProperty']) is currenly
autocasted into isset($simpleString[0]) - which is true.

Same goes for empty() since this is the same function.

This patch should resolve this problem:
Index: ZendEngine2/zend_execute.c
===================================================================
RCS file: /repository/ZendEngine2/zend_execute.c,v
retrieving revision 1.652.2.11
diff -u -r1.652.2.11 zend_execute.c
--- ZendEngine2/zend_execute.c  1 Dec 2004 14:01:58 -0000       1.652.2.11
+++ ZendEngine2/zend_execute.c  20 Dec 2004 01:08:28 -0000
@@ -4033,26 +4033,20 @@
                                result = 
Z_OBJ_HT_P(*container)->has_dimension(*container, offset,
(opline->extended_value == ZEND_ISEMPTY) TSRMLS_CC);
                        }
                } else if ((*container)->type == IS_STRING) { /* string offsets 
*/
-                       zval tmp_offset;
-
-                       if (Z_TYPE_P(offset) != IS_LONG) {
-                               tmp_offset = *offset;
-                               zval_copy_ctor(&tmp_offset);
-                               convert_to_long(&tmp_offset);
-                               offset = &tmp_offset;
-                       }
-                       switch (opline->extended_value) {
-                               case ZEND_ISSET:
-                                       if (offset->value.lval >= 0 && 
offset->value.lval <
Z_STRLEN_PP(container)) {
-                                               result = 1;
-                                       }
-                                       break;
-                               case ZEND_ISEMPTY:
-                                       if (offset->value.lval >= 0 && 
offset->value.lval <
Z_STRLEN_PP(container) && Z_STRVAL_PP(container)[offset->value.lval] !=
'0') {
-                                               result = 1;
-                                       }
-                                       break;
-                       }
+                       if (Z_TYPE_P(offset) == IS_LONG) {
+                       switch (opline->extended_value) {
+                               case ZEND_ISSET:
+                                       if (offset->value.lval >= 0 && 
offset->value.lval <
Z_STRLEN_PP(container)) {
+                                               result = 1;
+                                       }
+                                       break;
+                               case ZEND_ISEMPTY:
+                                       if (offset->value.lval >= 0 && 
offset->value.lval <
Z_STRLEN_PP(container) && Z_STRVAL_PP(container)[offset->value.lval] !=
'0') {
+                                               result = 1;
+                                       }
+                                       break;
+                       }
+            }
                }
        }
        


Besides this the files "zend_vm_execute.h" and "zend_vm_execute.h" seem
to have been messed up in CVS HEAD at the same commit?!.


Previous Comments:
------------------------------------------------------------------------

[2004-12-17 22:19:28] ptchristendom at yahoo dot com

Empty() has the same problem.

<?php
$simpleString = "Bogus String Text";
var_dump(empty($simpleString->nonExistentStringProperty));
?>

------------------------------------------------------------------------

[2004-12-15 17:27:33] jyounger at caedic dot com

Description:
------------
isset() when run using mod_php returns a false positive when checking a
string variable for the presence of a property. isset() when run under
the cli behaves correctly and returns false. This is in PHP 5.0.3RC2.

Reproduce code:
---------------
<?php
$simpleString = "Bogus String Text";

if (isset($simpleString->nonExistentStringProperty)) {
   echo "This line should not execute";
} else {
   echo "This line should execute";
}
?>

Expected result:
----------------
This line should execute

Actual result:
--------------
This line should not execute


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=31098&edit=1

Reply via email to