]> granicus.if.org Git - php/commitdiff
Fixed bug #80811
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 1 Mar 2021 14:01:09 +0000 (15:01 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 1 Mar 2021 15:30:01 +0000 (16:30 +0100)
When filling in defaults for skipped params, make sure that
reference parameters get the expected reference wrapper.

NEWS
Zend/tests/bug80811.phpt [new file with mode: 0644]
Zend/zend_execute.c

diff --git a/NEWS b/NEWS
index aefef64c289026fd2475e7b1489e285e17b9a5d2..6e5bd0516b7ccf377b1fa9c42f3a6bd654dec87f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ PHP                                                                        NEWS
 
 - Core:
   . Fixed bug #75776 (Flushing streams with compression filter is broken). (cmb)
+  . Fixed bug #80811 (Function exec without $output but with $restult_code
+    parameter crashes). (Nikita)
 
 - IMAP:
   . Fixed bug #80800 (imap_open() fails when the flags parameter includes
diff --git a/Zend/tests/bug80811.phpt b/Zend/tests/bug80811.phpt
new file mode 100644 (file)
index 0000000..e9f6443
--- /dev/null
@@ -0,0 +1,19 @@
+--TEST--
+Bug #80811: Function exec without $output but with $restult_code parameter crashes
+--FILE--
+<?php
+
+echo 'Executing with all params:' . PHP_EOL;
+exec('echo Something', output: $output, result_code: $resultCode);
+var_dump($resultCode);
+
+echo 'Executing without output param:' . PHP_EOL;
+exec('echo Something', result_code: $resultCode);
+var_dump($resultCode);
+
+?>
+--EXPECT--
+Executing with all params:
+int(0)
+Executing without output param:
+int(0)
index f6b2a6f9beab7555e117166bcc571cd84605ec18..69b0fb5242af2d61a9d41bd60c57e26e01c46434 100644 (file)
@@ -4579,6 +4579,9 @@ ZEND_API zend_result ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *cal
                        }
 
                        ZVAL_COPY_VALUE(arg, &default_value);
+                       if (ZEND_ARG_SEND_MODE(arg_info) & ZEND_SEND_BY_REF) {
+                               ZVAL_NEW_REF(arg, arg);
+                       }
                }
        }