summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Jones <sixd@php.net>2013-08-29 05:40:27 -0700
committerChristopher Jones <sixd@php.net>2013-08-29 05:40:27 -0700
commita4ff610e1c140b555d3cb2a7646e8ddfcb6420a7 (patch)
tree72ce6b5390381921d8acc40aa14b72ce65401c15
parent3697584e05f7a176e3b95e7cb1d8c02a0547f1ac (diff)
parent5015c4af6c1d2af992e0525f10e93b01043730e1 (diff)
downloadphp-git-a4ff610e1c140b555d3cb2a7646e8ddfcb6420a7.tar.gz
Merge branch 'PHP-5.5' of https://git.php.net/repository/php-src into PHP-5.5
* 'PHP-5.5' of https://git.php.net/repository/php-src: Fixed bug #65510 (5.5.2 crashes in _get_zval_ptr_ptr_var) Fixed bug #61759 (class_alias() should accept classes with leading backslashes). (Julien) Fixed bug #61759 (class_alias() should accept classes with leading backslashes). (Julien) Fixed compatibility with php-5.2 Fixed bug #65561 (Zend Opcache on Solaris 11 x86 needs ZEND_MM_ALIGNMENT=4). (Terry Ellison) Avoid compiler warning Fix bug #65579 (Using traits with get_class_methods causes segfault).
-rw-r--r--NEWS7
-rw-r--r--Zend/tests/bug65579.phpt29
-rw-r--r--Zend/zend_API.c24
-rw-r--r--Zend/zend_builtin_functions.c9
-rw-r--r--ext/opcache/Optimizer/pass1_5.c32
-rw-r--r--ext/opcache/Optimizer/zend_optimizer_internal.h3
-rw-r--r--ext/opcache/tests/bug65510.phpt20
7 files changed, 99 insertions, 25 deletions
diff --git a/NEWS b/NEWS
index dead9c78ea..518c9977b4 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,8 @@ PHP NEWS
--enable-dtrace). (Chris Jones, Kris Van Hees)
. Fixed bug #65225 (PHP_BINARY incorrectly set). (Patrick Allaert)
. Fixed bug #62692 (PHP fails to build with DTrace). (Chris Jones, Kris Van Hees)
+ . Fixed bug #61759 (class_alias() should accept classes with leading
+ backslashes). (Julien)
. Fixed bug #46311 (Pointer aliasing issue results in miscompile on gcc4.4).
(Nikita Popov)
@@ -22,6 +24,11 @@ PHP NEWS
. Fixed bug #65554 (createFromFormat broken when weekday name is followed
by some delimiters). (Valentin Logvinskiy, Stas).
+- OPCache:
+ . Fixed bug #65561 (Zend Opcache on Solaris 11 x86 needs ZEND_MM_ALIGNMENT=4).
+ (Terry Ellison)
+ . Fixed bug #65510 (5.5.2 crashes in _get_zval_ptr_ptr_var). (Dmitry)
+
- Openssl:
. Fixed bug #64802 (openssl_x509_parse fails to parse subject properly in
some cases). (Mark Jones)
diff --git a/Zend/tests/bug65579.phpt b/Zend/tests/bug65579.phpt
new file mode 100644
index 0000000000..25d74ed4f5
--- /dev/null
+++ b/Zend/tests/bug65579.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Bug #65579 (Using traits with get_class_methods causes segfault)
+--FILE--
+<?php
+trait ParentTrait {
+ public function testMethod() { }
+}
+
+trait ChildTrait {
+ use ParentTrait {
+ testMethod as testMethodFromParentTrait;
+ }
+ public function testMethod() { }
+}
+
+class TestClass {
+ use ChildTrait;
+}
+
+$obj = new TestClass();
+var_dump(get_class_methods($obj));
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ string(10) "testMethod"
+ [1]=>
+ string(25) "testmethodfromparenttrait"
+}
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 23ad158b17..b59faab284 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -2577,7 +2577,12 @@ ZEND_API int zend_register_class_alias_ex(const char *name, int name_len, zend_c
char *lcname = zend_str_tolower_dup(name, name_len);
int ret;
- ret = zend_hash_add(CG(class_table), lcname, name_len+1, &ce, sizeof(zend_class_entry *), NULL);
+ if (lcname[0] == '\\') {
+ ret = zend_hash_add(CG(class_table), lcname+1, name_len, &ce, sizeof(zend_class_entry *), NULL);
+ } else {
+ ret = zend_hash_add(CG(class_table), lcname, name_len+1, &ce, sizeof(zend_class_entry *), NULL);
+ }
+
efree(lcname);
if (ret == SUCCESS) {
ce->refcount++;
@@ -3980,15 +3985,16 @@ ZEND_API const char* zend_find_alias_name(zend_class_entry *ce, const char *name
{
zend_trait_alias *alias, **alias_ptr;
- alias_ptr = ce->trait_aliases;
- alias = *alias_ptr;
- while (alias) {
- if (alias->alias_len == len &&
- !strncasecmp(name, alias->alias, alias->alias_len)) {
- return alias->alias;
- }
- alias_ptr++;
+ if ((alias_ptr = ce->trait_aliases)) {
alias = *alias_ptr;
+ while (alias) {
+ if (alias->alias_len == len &&
+ !strncasecmp(name, alias->alias, alias->alias_len)) {
+ return alias->alias;
+ }
+ alias_ptr++;
+ alias = *alias_ptr;
+ }
}
return name;
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 44a480f2a1..1ad64e74ea 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -1399,15 +1399,8 @@ ZEND_FUNCTION(class_alias)
return;
}
- if (!autoload) {
- lc_name = do_alloca(class_name_len + 1, use_heap);
- zend_str_tolower_copy(lc_name, class_name, class_name_len);
+ found = zend_lookup_class_ex(class_name, class_name_len, NULL, autoload, &ce TSRMLS_CC);
- found = zend_hash_find(EG(class_table), lc_name, class_name_len+1, (void **) &ce);
- free_alloca(lc_name, use_heap);
- } else {
- found = zend_lookup_class(class_name, class_name_len, &ce TSRMLS_CC);
- }
if (found == SUCCESS) {
if ((*ce)->type == ZEND_USER_CLASS) {
if (zend_register_class_alias_ex(alias_name, alias_name_len, *ce TSRMLS_CC) == SUCCESS) {
diff --git a/ext/opcache/Optimizer/pass1_5.c b/ext/opcache/Optimizer/pass1_5.c
index 46406c383e..795b954173 100644
--- a/ext/opcache/Optimizer/pass1_5.c
+++ b/ext/opcache/Optimizer/pass1_5.c
@@ -408,6 +408,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
int var = opline->result.var;
int level = 0;
zend_op *op = opline + 1;
+ zend_op *use = NULL;
while (op < end) {
if (op->opcode == ZEND_BEGIN_SILENCE) {
@@ -420,21 +421,36 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
}
}
if (op->op1_type == IS_VAR && op->op1.var == var) {
- op->op1_type = IS_CV;
- op->op1.var = zend_optimizer_lookup_cv(op_array,
+ if (use) {
+ /* used more than once */
+ use = NULL;
+ break;
+ }
+ use = op;
+ } else if (op->op2_type == IS_VAR && op->op2.var == var) {
+ if (use) {
+ /* used more than once */
+ use = NULL;
+ break;
+ }
+ use = op;
+ }
+ op++;
+ }
+ if (use) {
+ if (use->op1_type == IS_VAR && use->op1.var == var) {
+ use->op1_type = IS_CV;
+ use->op1.var = zend_optimizer_lookup_cv(op_array,
Z_STRVAL(ZEND_OP1_LITERAL(opline)),
Z_STRLEN(ZEND_OP1_LITERAL(opline)));
MAKE_NOP(opline);
- break;
- } else if (op->op2_type == IS_VAR && op->op2.var == var) {
- op->op2_type = IS_CV;
- op->op2.var = zend_optimizer_lookup_cv(op_array,
+ } else if (use->op2_type == IS_VAR && use->op2.var == var) {
+ use->op2_type = IS_CV;
+ use->op2.var = zend_optimizer_lookup_cv(op_array,
Z_STRVAL(ZEND_OP1_LITERAL(opline)),
Z_STRLEN(ZEND_OP1_LITERAL(opline)));
MAKE_NOP(opline);
- break;
}
- op++;
}
}
break;
diff --git a/ext/opcache/Optimizer/zend_optimizer_internal.h b/ext/opcache/Optimizer/zend_optimizer_internal.h
index a9bad01be3..616bdf74f6 100644
--- a/ext/opcache/Optimizer/zend_optimizer_internal.h
+++ b/ext/opcache/Optimizer/zend_optimizer_internal.h
@@ -27,6 +27,9 @@
#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO
# define VAR_NUM(v) ((zend_uint)(EX_TMP_VAR_NUM(0, 0) - EX_TMP_VAR(0, v)))
# define NUM_VAR(v) ((zend_uint)(zend_uintptr_t)EX_TMP_VAR_NUM(0, v))
+#elif ZEND_EXTENSION_API_NO > PHP_5_2_X_API_NO
+# define VAR_NUM(v) ((v)/ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)))
+# define NUM_VAR(v) ((v)*ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)))
#else
# define VAR_NUM(v) ((v)/(sizeof(temp_variable)))
# define NUM_VAR(v) ((v)*(sizeof(temp_variable)))
diff --git a/ext/opcache/tests/bug65510.phpt b/ext/opcache/tests/bug65510.phpt
new file mode 100644
index 0000000000..ba19d27d6f
--- /dev/null
+++ b/ext/opcache/tests/bug65510.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #65510 (5.5.2 crashes in _get_zval_ptr_ptr_var)
+--INI--
+allow_url_include=1
+opcache.enable=1
+opcache.enable_cli=1
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+function parseQuery() {
+ $m = array("l", "a", "r", "u", "e", "n", "c", "e");
+ foreach($m as $n) {
+ @list($a, $b) = $n;
+ }
+}
+parseQuery();
+echo "ok\n";
+--EXPECT--
+ok