From: Aaron Piotrowski Date: Tue, 7 Jul 2015 16:37:33 +0000 (-0500) Subject: Allow NULL for exception_ce X-Git-Tag: php-7.0.0beta1~12^2~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=29c3cd44485fb8e43b29c46b1f9451e99bca92c8;p=php Allow NULL for exception_ce --- diff --git a/Zend/zend.c b/Zend/zend.c index 9e8613aa55..e5fd2e8bee 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -1296,11 +1296,20 @@ ZEND_API void zend_throw_error(zend_class_entry *exception_ce, const char *forma { va_list va; char *message = NULL; + + if (exception_ce) { + if (!instanceof_function(exception_ce, zend_ce_error)) { + zend_error(E_NOTICE, "Error exceptions must be derived from Error"); + exception_ce = zend_ce_error; + } + } else { + exception_ce = zend_ce_error; + } va_start(va, format); zend_vspprintf(&message, 0, format, va); - // TODO: we can't convert compile-time errors to exceptions yet??? + //TODO: we can't convert compile-time errors to exceptions yet??? if (EG(current_execute_data) && !CG(in_compilation)) { zend_throw_exception(exception_ce, message, 0); } else {