]> granicus.if.org Git - php/commitdiff
Allow NULL for exception_ce
authorAaron Piotrowski <aaron@trowski.com>
Tue, 7 Jul 2015 16:37:33 +0000 (11:37 -0500)
committerAaron Piotrowski <aaron@trowski.com>
Tue, 7 Jul 2015 17:10:55 +0000 (12:10 -0500)
Zend/zend.c

index 9e8613aa557100fadf79f48226f9182c46fcd663..e5fd2e8beeb74a7a8335d2225730825aae336429 100644 (file)
@@ -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 {