felipe                                   Sun, 01 Nov 2009 21:26:03 +0000

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

Log:
- Fixed bug #49908 (throwing exception in __autoload crashes when interface is 
not defined)

Bug: http://bugs.php.net/49908 (Verified) throwing exception in __autoload 
crashes when interface is not defined
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/NEWS
    A   php/php-src/branches/PHP_5_3/Zend/tests/bug49908.phpt
    U   php/php-src/branches/PHP_5_3/Zend/zend_vm_def.h
    U   php/php-src/branches/PHP_5_3/Zend/zend_vm_execute.h
    A   php/php-src/trunk/Zend/tests/bug49908.phpt
    U   php/php-src/trunk/Zend/zend_vm_def.h
    U   php/php-src/trunk/Zend/zend_vm_execute.h

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS   2009-11-01 17:30:55 UTC (rev 290128)
+++ php/php-src/branches/PHP_5_3/NEWS   2009-11-01 21:26:03 UTC (rev 290129)
@@ -16,6 +16,8 @@
   (Pierre)

 - Fixed bug #50023 (pdo_mysql doesn't use PHP_MYSQL_UNIX_SOCK_ADDR). (Ilia)
+- Fixed bug #49908 (throwing exception in __autoload crashes when interface
+  is not defined). (Felipe)
 - Fixed bug #49719 (ReflectionClass::hasProperty returns true for a private
   property in base class). (Felipe)
 - Fixed bug #49142 (crash when exception thrown from __tostring()).

Added: php/php-src/branches/PHP_5_3/Zend/tests/bug49908.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/tests/bug49908.phpt                       
        (rev 0)
+++ php/php-src/branches/PHP_5_3/Zend/tests/bug49908.phpt       2009-11-01 
21:26:03 UTC (rev 290129)
@@ -0,0 +1,28 @@
+--TEST--
+Bug #49908 (throwing exception in __autoload crashes when interface is not 
defined)
+--FILE--
+<?php
+
+function __autoload($className) {
+       var_dump($className);
+
+       if ($className == 'Foo') {
+               class Foo implements Bar {};
+       } else {
+               throw new Exception($className);
+       }
+}
+
+new Foo;
+
+?>
+--EXPECTF--
+%unicode|string%(3) "Foo"
+%unicode|string%(3) "Bar"
+
+Fatal error: Uncaught exception 'Exception' with message 'Bar' in %s:%d
+Stack trace:
+#0 %s(7): __autoload('Bar')
+#1 %s(13): __autoload('Foo')
+#2 {main}
+  thrown in %s on line %d


Property changes on: php/php-src/branches/PHP_5_3/Zend/tests/bug49908.phpt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

Modified: php/php-src/branches/PHP_5_3/Zend/zend_vm_def.h
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/zend_vm_def.h     2009-11-01 17:30:55 UTC 
(rev 290128)
+++ php/php-src/branches/PHP_5_3/Zend/zend_vm_def.h     2009-11-01 21:26:03 UTC 
(rev 290129)
@@ -4245,12 +4245,13 @@
        zend_class_entry *ce = EX_T(opline->op1.u.var).class_entry;
        zend_class_entry *iface = 
zend_fetch_class(Z_STRVAL(opline->op2.u.constant), 
Z_STRLEN(opline->op2.u.constant), opline->extended_value TSRMLS_CC);

-       if (!(iface->ce_flags & ZEND_ACC_INTERFACE)) {
-               zend_error_noreturn(E_ERROR, "%s cannot implement %s - it is 
not an interface", ce->name, iface->name);
+       if (iface) {
+               if (!(iface->ce_flags & ZEND_ACC_INTERFACE)) {
+                       zend_error_noreturn(E_ERROR, "%s cannot implement %s - 
it is not an interface", ce->name, iface->name);
+               }
+               zend_do_implement_interface(ce, iface TSRMLS_CC);
        }

-       zend_do_implement_interface(ce, iface TSRMLS_CC);
-
        ZEND_VM_NEXT_OPCODE();
 }


Modified: php/php-src/branches/PHP_5_3/Zend/zend_vm_execute.h
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/zend_vm_execute.h 2009-11-01 17:30:55 UTC 
(rev 290128)
+++ php/php-src/branches/PHP_5_3/Zend/zend_vm_execute.h 2009-11-01 21:26:03 UTC 
(rev 290129)
@@ -889,12 +889,13 @@
        zend_class_entry *ce = EX_T(opline->op1.u.var).class_entry;
        zend_class_entry *iface = 
zend_fetch_class(Z_STRVAL(opline->op2.u.constant), 
Z_STRLEN(opline->op2.u.constant), opline->extended_value TSRMLS_CC);

-       if (!(iface->ce_flags & ZEND_ACC_INTERFACE)) {
-               zend_error_noreturn(E_ERROR, "%s cannot implement %s - it is 
not an interface", ce->name, iface->name);
+       if (iface) {
+               if (!(iface->ce_flags & ZEND_ACC_INTERFACE)) {
+                       zend_error_noreturn(E_ERROR, "%s cannot implement %s - 
it is not an interface", ce->name, iface->name);
+               }
+               zend_do_implement_interface(ce, iface TSRMLS_CC);
        }

-       zend_do_implement_interface(ce, iface TSRMLS_CC);
-
        ZEND_VM_NEXT_OPCODE();
 }


Added: php/php-src/trunk/Zend/tests/bug49908.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/bug49908.phpt                          (rev 0)
+++ php/php-src/trunk/Zend/tests/bug49908.phpt  2009-11-01 21:26:03 UTC (rev 
290129)
@@ -0,0 +1,28 @@
+--TEST--
+Bug #49908 (throwing exception in __autoload crashes when interface is not 
defined)
+--FILE--
+<?php
+
+function __autoload($className) {
+       var_dump($className);
+
+       if ($className == 'Foo') {
+               class Foo implements Bar {};
+       } else {
+               throw new Exception($className);
+       }
+}
+
+new Foo;
+
+?>
+--EXPECTF--
+%unicode|string%(3) "Foo"
+%unicode|string%(3) "Bar"
+
+Fatal error: Uncaught exception 'Exception' with message 'Bar' in %s:%d
+Stack trace:
+#0 %s(7): __autoload('Bar')
+#1 %s(13): __autoload('Foo')
+#2 {main}
+  thrown in %s on line %d


Property changes on: php/php-src/trunk/Zend/tests/bug49908.phpt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

Modified: php/php-src/trunk/Zend/zend_vm_def.h
===================================================================
--- php/php-src/trunk/Zend/zend_vm_def.h        2009-11-01 17:30:55 UTC (rev 
290128)
+++ php/php-src/trunk/Zend/zend_vm_def.h        2009-11-01 21:26:03 UTC (rev 
290129)
@@ -4453,12 +4453,13 @@
        zend_class_entry *ce = EX_T(opline->op1.u.var).class_entry;
        zend_class_entry *iface = 
zend_u_fetch_class(Z_TYPE(opline->op2.u.constant), 
Z_UNIVAL(opline->op2.u.constant), Z_UNILEN(opline->op2.u.constant), 
opline->extended_value TSRMLS_CC);

-       if (!(iface->ce_flags & ZEND_ACC_INTERFACE)) {
-               zend_error_noreturn(E_ERROR, "%v cannot implement %v - it is 
not an interface", ce->name, iface->name);
+       if (iface) {
+               if (!(iface->ce_flags & ZEND_ACC_INTERFACE)) {
+                       zend_error_noreturn(E_ERROR, "%v cannot implement %v - 
it is not an interface", ce->name, iface->name);
+               }
+               zend_do_implement_interface(ce, iface TSRMLS_CC);
        }

-       zend_do_implement_interface(ce, iface TSRMLS_CC);
-
        ZEND_VM_NEXT_OPCODE();
 }


Modified: php/php-src/trunk/Zend/zend_vm_execute.h
===================================================================
--- php/php-src/trunk/Zend/zend_vm_execute.h    2009-11-01 17:30:55 UTC (rev 
290128)
+++ php/php-src/trunk/Zend/zend_vm_execute.h    2009-11-01 21:26:03 UTC (rev 
290129)
@@ -902,12 +902,13 @@
        zend_class_entry *ce = EX_T(opline->op1.u.var).class_entry;
        zend_class_entry *iface = 
zend_u_fetch_class(Z_TYPE(opline->op2.u.constant), 
Z_UNIVAL(opline->op2.u.constant), Z_UNILEN(opline->op2.u.constant), 
opline->extended_value TSRMLS_CC);

-       if (!(iface->ce_flags & ZEND_ACC_INTERFACE)) {
-               zend_error_noreturn(E_ERROR, "%v cannot implement %v - it is 
not an interface", ce->name, iface->name);
+       if (iface) {
+               if (!(iface->ce_flags & ZEND_ACC_INTERFACE)) {
+                       zend_error_noreturn(E_ERROR, "%v cannot implement %v - 
it is not an interface", ce->name, iface->name);
+               }
+               zend_do_implement_interface(ce, iface TSRMLS_CC);
        }

-       zend_do_implement_interface(ce, iface TSRMLS_CC);
-
        ZEND_VM_NEXT_OPCODE();
 }


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

Reply via email to