]> granicus.if.org Git - php/commitdiff
- Fixed bug #49908 (throwing exception in __autoload crashes when interface is not...
authorFelipe Pena <felipe@php.net>
Sun, 1 Nov 2009 21:26:03 +0000 (21:26 +0000)
committerFelipe Pena <felipe@php.net>
Sun, 1 Nov 2009 21:26:03 +0000 (21:26 +0000)
NEWS
Zend/tests/bug49908.phpt [new file with mode: 0644]
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

diff --git a/NEWS b/NEWS
index e663a5acd4ff0888f5adffc6f6824c336d45a5c7..a37691f0c1c362bf504c0aa1be204d1718c9a853 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,8 @@ PHP                                                                        NEWS
   (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()).
diff --git a/Zend/tests/bug49908.phpt b/Zend/tests/bug49908.phpt
new file mode 100644 (file)
index 0000000..08d6383
--- /dev/null
@@ -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
index f6f0c64dc2144728da667ad276052414f34335ba..621fecde07c4e27e87fa022da5d0d2ef9e6b0a0d 100644 (file)
@@ -4245,12 +4245,13 @@ ZEND_VM_HANDLER(144, ZEND_ADD_INTERFACE, ANY, CONST)
        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();
 }
 
index f2e25ac6a47e6da7fdf76f0bbbbcca2b9e853a78..e6fd0d314ff3ccdebe06080b1df4a87148985feb 100644 (file)
@@ -889,12 +889,13 @@ static int ZEND_FASTCALL  ZEND_ADD_INTERFACE_SPEC_CONST_HANDLER(ZEND_OPCODE_HAND
        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();
 }