dmitry                                   Mon, 14 Feb 2011 08:46:53 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=308315

Log:
Fixed Bug #53971 (isset() and empty() produce apparently spurious runtime error)

Bug: http://bugs.php.net/53971 (Assigned) isset() and empty() produce 
apparently spurious runtime error
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/NEWS
    A   php/php-src/branches/PHP_5_3/Zend/tests/bug53971.phpt
    U   php/php-src/branches/PHP_5_3/Zend/zend_execute.c
    A   php/php-src/trunk/Zend/tests/bug53971.phpt
    U   php/php-src/trunk/Zend/zend_execute.c

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS   2011-02-14 06:53:25 UTC (rev 308314)
+++ php/php-src/branches/PHP_5_3/NEWS   2011-02-14 08:46:53 UTC (rev 308315)
@@ -8,6 +8,8 @@
   . Indirect reference to $this fails to resolve if direct $this is never used
     in method. (Scott)
   . Added options to debug backtrace functions. (Stas)
+  . Fixed Bug #53971 (isset() and empty() produce apparently spurious runtime
+    error). (Dmitry)
   . Fixed Bug #53629 (memory leak inside highlight_string()). (Hannes, Ilia)
   . Fixed Bug #51458 (Lack of error context with nested exceptions). (Stas)
   . Fixed Bug #47143 (Throwing an exception in a destructor causes a fatal

Added: php/php-src/branches/PHP_5_3/Zend/tests/bug53971.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/tests/bug53971.phpt                       
        (rev 0)
+++ php/php-src/branches/PHP_5_3/Zend/tests/bug53971.phpt       2011-02-14 
08:46:53 UTC (rev 308315)
@@ -0,0 +1,11 @@
+--TEST--
+Bug #53971 (isset() and empty() produce apparently spurious runtime error)
+--FILE--
+<?php
+$s = "";
+var_dump(isset($s[0][0]));
+?>
+--EXPECT--
+bool(false)
+
+

Modified: php/php-src/branches/PHP_5_3/Zend/zend_execute.c
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/zend_execute.c    2011-02-14 06:53:25 UTC 
(rev 308314)
+++ php/php-src/branches/PHP_5_3/Zend/zend_execute.c    2011-02-14 08:46:53 UTC 
(rev 308315)
@@ -1067,7 +1067,7 @@
                                        dim = &tmp;
                                }
                                if (result) {
-                                       if (Z_LVAL_P(dim) < 0 || 
Z_STRLEN_P(container) <= Z_LVAL_P(dim)) {
+                                       if ((Z_LVAL_P(dim) < 0 || 
Z_STRLEN_P(container) <= Z_LVAL_P(dim)) && type != BP_VAR_IS) {
                                                zend_error(E_NOTICE, 
"Uninitialized string offset: %ld", Z_LVAL_P(dim));
                                        }
                                        result->str_offset.str = container;

Added: php/php-src/trunk/Zend/tests/bug53971.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/bug53971.phpt                          (rev 0)
+++ php/php-src/trunk/Zend/tests/bug53971.phpt  2011-02-14 08:46:53 UTC (rev 
308315)
@@ -0,0 +1,11 @@
+--TEST--
+Bug #53971 (isset() and empty() produce apparently spurious runtime error)
+--FILE--
+<?php
+$s = "";
+var_dump(isset($s[0][0]));
+?>
+--EXPECT--
+bool(false)
+
+

Modified: php/php-src/trunk/Zend/zend_execute.c
===================================================================
--- php/php-src/trunk/Zend/zend_execute.c       2011-02-14 06:53:25 UTC (rev 
308314)
+++ php/php-src/trunk/Zend/zend_execute.c       2011-02-14 08:46:53 UTC (rev 
308315)
@@ -1258,7 +1258,9 @@
                                Z_TYPE_P(ptr) = IS_STRING;

                                if (Z_LVAL_P(dim) < 0 || Z_STRLEN_P(container) 
<= Z_LVAL_P(dim)) {
-                                       zend_error(E_NOTICE, "Uninitialized 
string offset: %ld", Z_LVAL_P(dim));
+                                       if (type != BP_VAR_IS) {
+                                               zend_error(E_NOTICE, 
"Uninitialized string offset: %ld", Z_LVAL_P(dim));
+                                       }
                                        Z_STRVAL_P(ptr) = STR_EMPTY_ALLOC();
                                        Z_STRLEN_P(ptr) = 0;
                                } else {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to