From 75a04eac978333467ccd98225d7ef21942ce9e91 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 6 Mar 2020 14:57:55 +0100 Subject: Make exit() unwind properly exit() is now internally implemented by throwing an exception, performing a normal stack unwind and a clean shutdown. This ensures that no persistent resource leaks occur. The exception is internal, cannot be caught and does not result in the execution of finally blocks. This may be relaxed in the future. Closes GH-5768. --- sapi/phpdbg/phpdbg_prompt.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sapi/phpdbg/phpdbg_prompt.c') diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index 2f0e8e2440..f6b5ef41e5 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -1711,6 +1711,11 @@ void phpdbg_execute_ex(zend_execute_data *execute_data) /* {{{ */ } #endif + if (exception && zend_is_unwind_exit(exception)) { + /* Restore bailout based exit. */ + zend_bailout(); + } + if (PHPDBG_G(flags) & PHPDBG_PREVENT_INTERACTIVE) { phpdbg_print_opline_ex(execute_data, 0); goto next; -- cgit v1.2.1