summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rwxr-xr-xZend/tests/bug60978.phpt10
-rw-r--r--Zend/zend_execute_API.c6
3 files changed, 15 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 43dfe1329e..10111c619c 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ PHP NEWS
- Core:
. Fixed bug #60573 (type hinting with "self" keyword causes weird errors).
(Laruence)
+ . Fixed bug #60978 (exit code incorrect). (Laruence)
- cURL:
. Added support for CURLOPT_FTP_RESPONSE_TIMEOUT, CURLOPT_APPEND,
diff --git a/Zend/tests/bug60978.phpt b/Zend/tests/bug60978.phpt
new file mode 100755
index 0000000000..ebaaf05f23
--- /dev/null
+++ b/Zend/tests/bug60978.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Bug #60978 (exit code incorrect)
+--FILE--
+<?php
+$php = getenv('TEST_PHP_EXECUTABLE');
+exec($php . ' -r "exit(2);"', $output, $exit_code);
+echo $exit_code;
+?>
+--EXPECT--
+2
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index f9048dada3..10adfb6a26 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -1195,11 +1195,12 @@ ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char *s
}
CG(interactive) = 0;
- retval = SUCCESS;
zend_try {
zend_execute(new_op_array TSRMLS_CC);
} zend_catch {
- retval = FAILURE;
+ destroy_op_array(new_op_array TSRMLS_CC);
+ efree(new_op_array);
+ zend_bailout();
} zend_end_try();
CG(interactive) = orig_interactive;
@@ -1221,6 +1222,7 @@ ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char *s
destroy_op_array(new_op_array TSRMLS_CC);
efree(new_op_array);
EG(return_value_ptr_ptr) = original_return_value_ptr_ptr;
+ retval = SUCCESS;
} else {
retval = FAILURE;
}