summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--Zend/tests/bug49908.phpt28
-rw-r--r--Zend/zend_vm_def.h9
-rw-r--r--Zend/zend_vm_execute.h9
4 files changed, 40 insertions, 8 deletions
diff --git a/NEWS b/NEWS
index e663a5acd4..a37691f0c1 100644
--- 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
index 0000000000..08d6383d83
--- /dev/null
+++ b/Zend/tests/bug49908.phpt
@@ -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
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index f6f0c64dc2..621fecde07 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -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();
}
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index f2e25ac6a4..e6fd0d314f 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -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();
}