Skip to content

Commit a4ff610

Browse files
committed
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).
2 parents 3697584 + 5015c4a commit a4ff610

File tree

7 files changed

+99
-25
lines changed

7 files changed

+99
-25
lines changed

NEWS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ PHP NEWS
1212
--enable-dtrace). (Chris Jones, Kris Van Hees)
1313
. Fixed bug #65225 (PHP_BINARY incorrectly set). (Patrick Allaert)
1414
. Fixed bug #62692 (PHP fails to build with DTrace). (Chris Jones, Kris Van Hees)
15+
. Fixed bug #61759 (class_alias() should accept classes with leading
16+
backslashes). (Julien)
1517
. Fixed bug #46311 (Pointer aliasing issue results in miscompile on gcc4.4).
1618
(Nikita Popov)
1719

@@ -22,6 +24,11 @@ PHP NEWS
2224
. Fixed bug #65554 (createFromFormat broken when weekday name is followed
2325
by some delimiters). (Valentin Logvinskiy, Stas).
2426

27+
- OPCache:
28+
. Fixed bug #65561 (Zend Opcache on Solaris 11 x86 needs ZEND_MM_ALIGNMENT=4).
29+
(Terry Ellison)
30+
. Fixed bug #65510 (5.5.2 crashes in _get_zval_ptr_ptr_var). (Dmitry)
31+
2532
- Openssl:
2633
. Fixed bug #64802 (openssl_x509_parse fails to parse subject properly in
2734
some cases). (Mark Jones)

Zend/tests/bug65579.phpt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
Bug #65579 (Using traits with get_class_methods causes segfault)
3+
--FILE--
4+
<?php
5+
trait ParentTrait {
6+
public function testMethod() { }
7+
}
8+
9+
trait ChildTrait {
10+
use ParentTrait {
11+
testMethod as testMethodFromParentTrait;
12+
}
13+
public function testMethod() { }
14+
}
15+
16+
class TestClass {
17+
use ChildTrait;
18+
}
19+
20+
$obj = new TestClass();
21+
var_dump(get_class_methods($obj));
22+
?>
23+
--EXPECT--
24+
array(2) {
25+
[0]=>
26+
string(10) "testMethod"
27+
[1]=>
28+
string(25) "testmethodfromparenttrait"
29+
}

Zend/zend_API.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,7 +2577,12 @@ ZEND_API int zend_register_class_alias_ex(const char *name, int name_len, zend_c
25772577
char *lcname = zend_str_tolower_dup(name, name_len);
25782578
int ret;
25792579

2580-
ret = zend_hash_add(CG(class_table), lcname, name_len+1, &ce, sizeof(zend_class_entry *), NULL);
2580+
if (lcname[0] == '\\') {
2581+
ret = zend_hash_add(CG(class_table), lcname+1, name_len, &ce, sizeof(zend_class_entry *), NULL);
2582+
} else {
2583+
ret = zend_hash_add(CG(class_table), lcname, name_len+1, &ce, sizeof(zend_class_entry *), NULL);
2584+
}
2585+
25812586
efree(lcname);
25822587
if (ret == SUCCESS) {
25832588
ce->refcount++;
@@ -3980,15 +3985,16 @@ ZEND_API const char* zend_find_alias_name(zend_class_entry *ce, const char *name
39803985
{
39813986
zend_trait_alias *alias, **alias_ptr;
39823987

3983-
alias_ptr = ce->trait_aliases;
3984-
alias = *alias_ptr;
3985-
while (alias) {
3986-
if (alias->alias_len == len &&
3987-
!strncasecmp(name, alias->alias, alias->alias_len)) {
3988-
return alias->alias;
3989-
}
3990-
alias_ptr++;
3988+
if ((alias_ptr = ce->trait_aliases)) {
39913989
alias = *alias_ptr;
3990+
while (alias) {
3991+
if (alias->alias_len == len &&
3992+
!strncasecmp(name, alias->alias, alias->alias_len)) {
3993+
return alias->alias;
3994+
}
3995+
alias_ptr++;
3996+
alias = *alias_ptr;
3997+
}
39923998
}
39933999

39944000
return name;

Zend/zend_builtin_functions.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,15 +1399,8 @@ ZEND_FUNCTION(class_alias)
13991399
return;
14001400
}
14011401

1402-
if (!autoload) {
1403-
lc_name = do_alloca(class_name_len + 1, use_heap);
1404-
zend_str_tolower_copy(lc_name, class_name, class_name_len);
1402+
found = zend_lookup_class_ex(class_name, class_name_len, NULL, autoload, &ce TSRMLS_CC);
14051403

1406-
found = zend_hash_find(EG(class_table), lc_name, class_name_len+1, (void **) &ce);
1407-
free_alloca(lc_name, use_heap);
1408-
} else {
1409-
found = zend_lookup_class(class_name, class_name_len, &ce TSRMLS_CC);
1410-
}
14111404
if (found == SUCCESS) {
14121405
if ((*ce)->type == ZEND_USER_CLASS) {
14131406
if (zend_register_class_alias_ex(alias_name, alias_name_len, *ce TSRMLS_CC) == SUCCESS) {

ext/opcache/Optimizer/pass1_5.c

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
408408
int var = opline->result.var;
409409
int level = 0;
410410
zend_op *op = opline + 1;
411+
zend_op *use = NULL;
411412

412413
while (op < end) {
413414
if (op->opcode == ZEND_BEGIN_SILENCE) {
@@ -420,21 +421,36 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
420421
}
421422
}
422423
if (op->op1_type == IS_VAR && op->op1.var == var) {
423-
op->op1_type = IS_CV;
424-
op->op1.var = zend_optimizer_lookup_cv(op_array,
424+
if (use) {
425+
/* used more than once */
426+
use = NULL;
427+
break;
428+
}
429+
use = op;
430+
} else if (op->op2_type == IS_VAR && op->op2.var == var) {
431+
if (use) {
432+
/* used more than once */
433+
use = NULL;
434+
break;
435+
}
436+
use = op;
437+
}
438+
op++;
439+
}
440+
if (use) {
441+
if (use->op1_type == IS_VAR && use->op1.var == var) {
442+
use->op1_type = IS_CV;
443+
use->op1.var = zend_optimizer_lookup_cv(op_array,
425444
Z_STRVAL(ZEND_OP1_LITERAL(opline)),
426445
Z_STRLEN(ZEND_OP1_LITERAL(opline)));
427446
MAKE_NOP(opline);
428-
break;
429-
} else if (op->op2_type == IS_VAR && op->op2.var == var) {
430-
op->op2_type = IS_CV;
431-
op->op2.var = zend_optimizer_lookup_cv(op_array,
447+
} else if (use->op2_type == IS_VAR && use->op2.var == var) {
448+
use->op2_type = IS_CV;
449+
use->op2.var = zend_optimizer_lookup_cv(op_array,
432450
Z_STRVAL(ZEND_OP1_LITERAL(opline)),
433451
Z_STRLEN(ZEND_OP1_LITERAL(opline)));
434452
MAKE_NOP(opline);
435-
break;
436453
}
437-
op++;
438454
}
439455
}
440456
break;

ext/opcache/Optimizer/zend_optimizer_internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO
2828
# define VAR_NUM(v) ((zend_uint)(EX_TMP_VAR_NUM(0, 0) - EX_TMP_VAR(0, v)))
2929
# define NUM_VAR(v) ((zend_uint)(zend_uintptr_t)EX_TMP_VAR_NUM(0, v))
30+
#elif ZEND_EXTENSION_API_NO > PHP_5_2_X_API_NO
31+
# define VAR_NUM(v) ((v)/ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)))
32+
# define NUM_VAR(v) ((v)*ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)))
3033
#else
3134
# define VAR_NUM(v) ((v)/(sizeof(temp_variable)))
3235
# define NUM_VAR(v) ((v)*(sizeof(temp_variable)))

ext/opcache/tests/bug65510.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #65510 (5.5.2 crashes in _get_zval_ptr_ptr_var)
3+
--INI--
4+
allow_url_include=1
5+
opcache.enable=1
6+
opcache.enable_cli=1
7+
--SKIPIF--
8+
<?php require_once('skipif.inc'); ?>
9+
--FILE--
10+
<?php
11+
function parseQuery() {
12+
$m = array("l", "a", "r", "u", "e", "n", "c", "e");
13+
foreach($m as $n) {
14+
@list($a, $b) = $n;
15+
}
16+
}
17+
parseQuery();
18+
echo "ok\n";
19+
--EXPECT--
20+
ok

0 commit comments

Comments
 (0)