com php-src: Fixed bug #71248 (Wrong interface is enforced): NEWS Zend/tests/bug71248.phpt Zend/zend_inheritance.c

From: Date: Wed, 13 Jan 2016 08:41:57 +0000
Subject: com php-src: Fixed bug #71248 (Wrong interface is enforced): NEWS Zend/tests/bug71248.phpt Zend/zend_inheritance.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-90629@lists.php.net to get a copy of this message
Commit: 50be2c89bed61a1928cd1dd0c226fe62769344dd Author: Dmitry Stogov <dmitry@zend.com> Wed, 13 Jan 2016 11:41:57 +0300 Parents: c3c6ab08fe2125969cc769b1862623069d021a97 Branches: PHP-7.0 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=50be2c89bed61a1928cd1dd0c226fe62769344dd Log: Fixed bug #71248 (Wrong interface is enforced) Bugs: https://bugs.php.net/71248 Changed paths: M NEWS A Zend/tests/bug71248.phpt M Zend/zend_inheritance.c Diff: diff --git a/NEWS b/NEWS index 581e122..9ce138a 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,7 @@ PHP NEWS . Fix >2G Content-Length headers in apache2handler. (Adam Harvey) - Core: + . Fixed bug #71248 (Wrong interface is enforced). (Dmitry) . Fixed bug #71300 (Segfault in zend_fetch_string_offset). (Laruence) . Fixed bug #71221 (Null pointer deref (segfault) in get_defined_vars via ob_start). (hugh at allthethings dot co dot nz) diff --git a/Zend/tests/bug71248.phpt b/Zend/tests/bug71248.phpt new file mode 100644 index 0000000..6be2585 --- /dev/null +++ b/Zend/tests/bug71248.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #71248 (Wrong interface is enforced) +--FILE-- +<?php +class Hint1 { } +class Hint2 { } + +abstract class Base { + public function __construct(Hint1 $x) { } +} + +interface Iface { + public function __construct(Hint1 $x); +} + +class Foo extends Base implements Iface { +} + +$code = <<<'PHP' +abstract class Bar extends Base { + public function __construct(Hint2 $x) { } +} +PHP; +eval($code); +?> +OK +--EXPECT-- +OK diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index ac98627..9eb7a0b 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -585,7 +585,20 @@ static zend_function *do_inherit_method(zend_string *key, zend_function *parent, zval *child = zend_hash_find(&ce->function_table, key); if (child) { - do_inheritance_check_on_method((zend_function*)Z_PTR_P(child), parent); + zend_function *func = (zend_function*)Z_PTR_P(child); + zend_function *orig_prototype = func->common..prototype; + + do_inheritance_check_on_method(func, parent); + if (func->common.prototype != orig_prototype && + func->type == ZEND_USER_FUNCTION && + func->common.scope != ce && + !func->op_array.static_variables) { + /* Lazy duplication */ + zend_function *new_function = zend_arena_alloc(&CG(arena), sizeof(zend_op_array)); + memcpy(new_function, func, sizeof(zend_op_array)); + Z_PTR_P(child) = new_function; + func->common.prototype = orig_prototype; + } return NULL; }

« previous php.cvs (#90629) next »