com php-src: Fix bug #67938: Segfault when extending interface method with variadic: NEWS Zend/tests/bug67938.phpt Zend/zend_compile.c

From: Date: Sat, 30 Aug 2014 18:43:34 +0000
Subject: com php-src: Fix bug #67938: Segfault when extending interface method with variadic: NEWS Zend/tests/bug67938.phpt Zend/zend_compile.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-81314@lists.php.net to get a copy of this message
Commit: d7368c2531ad1268d43c894b8422a61b70c70e5a Author: Nikita Popov <nikic@php.net> Sat, 30 Aug 2014 20:41:36 +0200 Parents: daefca44b5ed60b6adb1238babbf3a51e8541404 Branches: PHP-5.6 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d7368c2531ad1268d43c894b8422a61b70c70e5a Log: Fix bug #67938: Segfault when extending interface method with variadic We only want to check extra optional args if the proto function is variadic, not when we're adding extra variadic args. Bugs: https://bugs.php.net/67938 Changed paths: M NEWS A Zend/tests/bug67938.phpt M Zend/zend_compile.c Diff: diff --git a/NEWS b/NEWS index 5473aba..f6e116d 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,8 @@ PHP NEWS - Core: . Fixed bug #67878 (program_prefix not honoured in man pages). (Remi) + . Fixed bug #67938 (Segfault when extending interface method with variadic). + (Nikita) - Fileinfo: . Fixed bug #67731 (finfo::file() returns invalid mime type @@ -15,7 +17,7 @@ PHP NEWS - GMP: . Fixed bug #67917 (Using GMP objects with overloaded operators can cause - memory exhaustion). (Nikita Popov) + memory exhaustion). (Nikita) - MySQLi: . Fixed bug #67839 (mysqli does not handle 4-byte floats correctly). (Keyur) diff --git a/Zend/tests/bug67938.phpt b/Zend/tests/bug67938.phpt new file mode 100644 index 0000000..6597c48 --- /dev/null +++ b/Zend/tests/bug67938.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #67938: Segfault when extending interface method with variadic +--FILE-- +<?php + +interface TestInterface { + public function foo(); + public function bar(array $bar); +} + +class Test implements TestInterface { + public function foo(...$args) { + echo __METHOD__, "\n"; + } + public function bar(array $bar, ...$args) { + echo __METHOD__, "\n"; + } +} + +$obj = new Test; +$obj->foo(); +$obj->bar([]); + +?> +--EXPECT-- +Test::foo +Test::bar diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 7c979d5..54b01a8 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3258,7 +3258,7 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c * go through all the parameters of the function and not just those present in the * prototype. */ num_args = proto->common.num_args; - if ((fe->common.fn_flags & ZEND_ACC_VARIADIC) + if ((proto->common.fn_flags & ZEND_ACC_VARIADIC) && fe->common.num_args > proto->common.num_args) { num_args = fe->common.num_args; }

« previous php.cvs (#81314) next »