Merge branch 'PHP-7.0' of git.php.net:/php-src into PHP-7.0

This commit is contained in:
Xinchen Hui 2016-01-06 00:02:53 +08:00
commit ce2b2f7e0a
5 changed files with 78 additions and 16 deletions

27
Zend/tests/bug71275.phpt Normal file
View File

@ -0,0 +1,27 @@
--TEST--
Bug #71275 (Bad method called on cloning an object having a trait)
--FILE--
<?php
trait MyTrait {
public function _() {
throw new RuntimeException('Should not be called');
}
}
class MyClass {
use MyTrait;
public function __clone() {
echo "I'm working hard to clone";
}
}
$instance = new MyClass();
clone $instance;
?>
--EXPECT--
I'm working hard to clone

View File

@ -1026,34 +1026,34 @@ static zend_bool zend_traits_method_compatibility_check(zend_function *fn, zend_
static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zend_function* fe) /* {{{ */ static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zend_function* fe) /* {{{ */
{ {
if (!strncmp(ZSTR_VAL(mname), ZEND_CLONE_FUNC_NAME, ZSTR_LEN(mname))) { if (zend_string_equals_literal(mname, ZEND_CLONE_FUNC_NAME)) {
ce->clone = fe; fe->common.fn_flags |= ZEND_ACC_CLONE; ce->clone = fe; fe->common.fn_flags |= ZEND_ACC_CLONE;
} else if (!strncmp(ZSTR_VAL(mname), ZEND_CONSTRUCTOR_FUNC_NAME, ZSTR_LEN(mname))) { } else if (zend_string_equals_literal(mname, ZEND_CONSTRUCTOR_FUNC_NAME)) {
if (ce->constructor && (!ce->parent || ce->constructor != ce->parent->constructor)) { if (ce->constructor && (!ce->parent || ce->constructor != ce->parent->constructor)) {
zend_error_noreturn(E_COMPILE_ERROR, "%s has colliding constructor definitions coming from traits", ZSTR_VAL(ce->name)); zend_error_noreturn(E_COMPILE_ERROR, "%s has colliding constructor definitions coming from traits", ZSTR_VAL(ce->name));
} }
ce->constructor = fe; fe->common.fn_flags |= ZEND_ACC_CTOR; ce->constructor = fe; fe->common.fn_flags |= ZEND_ACC_CTOR;
} else if (!strncmp(ZSTR_VAL(mname), ZEND_DESTRUCTOR_FUNC_NAME, ZSTR_LEN(mname))) { } else if (zend_string_equals_literal(mname, ZEND_DESTRUCTOR_FUNC_NAME)) {
ce->destructor = fe; fe->common.fn_flags |= ZEND_ACC_DTOR; ce->destructor = fe; fe->common.fn_flags |= ZEND_ACC_DTOR;
} else if (!strncmp(ZSTR_VAL(mname), ZEND_GET_FUNC_NAME, ZSTR_LEN(mname))) { } else if (zend_string_equals_literal(mname, ZEND_GET_FUNC_NAME)) {
ce->__get = fe; ce->__get = fe;
ce->ce_flags |= ZEND_ACC_USE_GUARDS; ce->ce_flags |= ZEND_ACC_USE_GUARDS;
} else if (!strncmp(ZSTR_VAL(mname), ZEND_SET_FUNC_NAME, ZSTR_LEN(mname))) { } else if (zend_string_equals_literal(mname, ZEND_SET_FUNC_NAME)) {
ce->__set = fe; ce->__set = fe;
ce->ce_flags |= ZEND_ACC_USE_GUARDS; ce->ce_flags |= ZEND_ACC_USE_GUARDS;
} else if (!strncmp(ZSTR_VAL(mname), ZEND_CALL_FUNC_NAME, ZSTR_LEN(mname))) { } else if (zend_string_equals_literal(mname, ZEND_CALL_FUNC_NAME)) {
ce->__call = fe; ce->__call = fe;
} else if (!strncmp(ZSTR_VAL(mname), ZEND_UNSET_FUNC_NAME, ZSTR_LEN(mname))) { } else if (zend_string_equals_literal(mname, ZEND_UNSET_FUNC_NAME)) {
ce->__unset = fe; ce->__unset = fe;
ce->ce_flags |= ZEND_ACC_USE_GUARDS; ce->ce_flags |= ZEND_ACC_USE_GUARDS;
} else if (!strncmp(ZSTR_VAL(mname), ZEND_ISSET_FUNC_NAME, ZSTR_LEN(mname))) { } else if (zend_string_equals_literal(mname, ZEND_ISSET_FUNC_NAME)) {
ce->__isset = fe; ce->__isset = fe;
ce->ce_flags |= ZEND_ACC_USE_GUARDS; ce->ce_flags |= ZEND_ACC_USE_GUARDS;
} else if (!strncmp(ZSTR_VAL(mname), ZEND_CALLSTATIC_FUNC_NAME, ZSTR_LEN(mname))) { } else if (zend_string_equals_literal(mname, ZEND_CALLSTATIC_FUNC_NAME)) {
ce->__callstatic = fe; ce->__callstatic = fe;
} else if (!strncmp(ZSTR_VAL(mname), ZEND_TOSTRING_FUNC_NAME, ZSTR_LEN(mname))) { } else if (zend_string_equals_literal(mname, ZEND_TOSTRING_FUNC_NAME)) {
ce->__tostring = fe; ce->__tostring = fe;
} else if (!strncmp(ZSTR_VAL(mname), ZEND_DEBUGINFO_FUNC_NAME, ZSTR_LEN(mname))) { } else if (zend_string_equals_literal(mname, ZEND_DEBUGINFO_FUNC_NAME)) {
ce->__debugInfo = fe; ce->__debugInfo = fe;
} else if (ZSTR_LEN(ce->name) == ZSTR_LEN(mname)) { } else if (ZSTR_LEN(ce->name) == ZSTR_LEN(mname)) {
zend_string *lowercase_name = zend_string_tolower(ce->name); zend_string *lowercase_name = zend_string_tolower(ce->name);

View File

@ -723,9 +723,20 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ
if (PG(html_errors)) { if (PG(html_errors)) {
replace_buffer = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT, NULL); replace_buffer = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT, NULL);
/* Retry with substituting invalid chars on fail. */
if (!replace_buffer || ZSTR_LEN(replace_buffer) < 1) {
replace_buffer = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT | ENT_HTML_SUBSTITUTE_ERRORS, NULL);
}
efree(buffer); efree(buffer);
if (replace_buffer) {
buffer = ZSTR_VAL(replace_buffer); buffer = ZSTR_VAL(replace_buffer);
buffer_len = (int)ZSTR_LEN(replace_buffer); buffer_len = (int)ZSTR_LEN(replace_buffer);
} else {
buffer = "";
buffer_len = 0;
}
} }
/* which function caused the problem if any at all */ /* which function caused the problem if any at all */
@ -878,8 +889,10 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ
if (replace_buffer) { if (replace_buffer) {
zend_string_free(replace_buffer); zend_string_free(replace_buffer);
} else { } else {
if (buffer_len > 0) {
efree(buffer); efree(buffer);
} }
}
php_error(type, "%s", message); php_error(type, "%s", message);
efree(message); efree(message);

View File

@ -602,6 +602,7 @@ static int alter_ini( const char * pKey, int keyLen, const char * pValue, int va
else else
{ {
#if PHP_MAJOR_VERSION >= 7 #if PHP_MAJOR_VERSION >= 7
--keyLen;
psKey = zend_string_init(pKey, keyLen, 1); psKey = zend_string_init(pKey, keyLen, 1);
zend_alter_ini_entry_chars(psKey, zend_alter_ini_entry_chars(psKey,
(char *)pValue, valLen, (char *)pValue, valLen,

21
tests/basic/bug71273.phpt Normal file
View File

@ -0,0 +1,21 @@
--TEST--
Bug #71273 A wrong ext directory setup in php.ini leads to crash
--SKIPIF--
<?php
if ("cli" != php_sapi_name()) {
die("skip CLI only");
}
?>
--FILE--
<?php
/* NOTE this file is required to be encoded in iso-8859-1 */
$cmd = getenv('TEST_PHP_EXECUTABLE') . " -n -d html_errors=on -d extension_dir=a/é/w -d extension=php_kartoffelbrei.dll -v 2>&1";
$out = shell_exec($cmd);
var_dump(preg_match(",.+a[\\/].+[\\/]w.php_kartoffelbrei.dll.+,s", $out));
?>
==DONE==
--EXPECTF--
int(1)
==DONE==