Skip to content

Commit 43a5cdd

Browse files
committed
Merge branch 'master' into jit-dynasm
* master: Use interned empty and "one char" strings. Remove unused opcode handlers follow up fix on bug #74022 Bugfix 63790 - Don't try to use Spoofchecker when unavailable Removed useless dereferences Fixed bug #74606 (Segfault within try/catch/finally nesting in Generators) Added cleanup Added test for bug #74600 Added test for bug #74596
2 parents e1375f3 + a08723d commit 43a5cdd

File tree

19 files changed

+799
-849
lines changed

19 files changed

+799
-849
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ PHP NEWS
104104
. Fixed bug #74433 (wrong reflection for Normalizer methods). (villfa)
105105
. Fixed bug #74439 (wrong reflection for Locale methods). (villfa)
106106
. Fixed bug #74468 (wrong reflection on Collator::sortWithSortKeys). (villfa)
107+
. Fixed bug #63790 (test using Spoofchecker which may be unavailable). (Sara)
107108

108109
- Mbstring:
109110
. Implemented request #66024 (mb_chr() and mb_ord()). (Masakielastic, Yasuo)

Zend/tests/generators/bug74606.phpt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
Bug #74606 (Segfault within try/catch/finally nesting in Generators)
3+
--FILE--
4+
<?php
5+
6+
function gen() {
7+
$array = ["foo"];
8+
$array[] = "bar";
9+
10+
foreach ($array as $item) {
11+
try {
12+
try {
13+
yield;
14+
} finally {
15+
echo "fin $item\n";
16+
}
17+
} catch (\Exception $e) {
18+
echo "catch\n";
19+
continue;
20+
}
21+
}
22+
}
23+
gen()->throw(new Exception);
24+
25+
?>
26+
--EXPECT--
27+
fin foo
28+
catch
29+
fin bar

Zend/zend_compile.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7298,6 +7298,9 @@ void zend_compile_array(znode *result, zend_ast *ast) /* {{{ */
72987298
return;
72997299
}
73007300

7301+
/* Empty arrays are handled at compile-time */
7302+
ZEND_ASSERT(list->children > 0);
7303+
73017304
for (i = 0; i < list->children; ++i) {
73027305
zend_ast *elem_ast = list->child[i];
73037306
zend_ast *value_ast, *key_ast;
@@ -7341,11 +7344,6 @@ void zend_compile_array(znode *result, zend_ast *ast) /* {{{ */
73417344
}
73427345
}
73437346

7344-
/* Handle empty array */
7345-
if (!list->children) {
7346-
zend_emit_op_tmp(result, ZEND_INIT_ARRAY, NULL, NULL);
7347-
}
7348-
73497347
/* Add a flag to INIT_ARRAY if we know this array cannot be packed */
73507348
if (!packed) {
73517349
ZEND_ASSERT(opnum_init != (uint32_t)-1);

Zend/zend_generators.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static void zend_generator_cleanup_unfinished_execution(
108108
if (UNEXPECTED(generator->frozen_call_stack)) {
109109
zend_generator_restore_call_stack(generator);
110110
}
111-
zend_cleanup_unfinished_execution(execute_data, op_num, 0);
111+
zend_cleanup_unfinished_execution(execute_data, op_num, catch_op_num);
112112
}
113113
}
114114
/* }}} */

Zend/zend_operators.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ ZEND_API void ZEND_FASTCALL _convert_to_string(zval *op ZEND_FILE_LINE_DC) /* {{
537537
break;
538538
}
539539
case IS_LONG: {
540-
ZVAL_NEW_STR(op, zend_long_to_str(Z_LVAL_P(op)));
540+
ZVAL_STR(op, zend_long_to_str(Z_LVAL_P(op)));
541541
break;
542542
}
543543
case IS_DOUBLE: {
@@ -2856,9 +2856,13 @@ ZEND_API void ZEND_FASTCALL zend_locale_sprintf_double(zval *op ZEND_FILE_LINE_D
28562856

28572857
ZEND_API zend_string* ZEND_FASTCALL zend_long_to_str(zend_long num) /* {{{ */
28582858
{
2859-
char buf[MAX_LENGTH_OF_LONG + 1];
2860-
char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, num);
2861-
return zend_string_init(res, buf + sizeof(buf) - 1 - res, 0);
2859+
if ((zend_ulong)num <= 9) {
2860+
return ZSTR_CHAR((zend_uchar)'0' + (zend_uchar)num);
2861+
} else {
2862+
char buf[MAX_LENGTH_OF_LONG + 1];
2863+
char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, num);
2864+
return zend_string_init(res, buf + sizeof(buf) - 1 - res, 0);
2865+
}
28622866
}
28632867
/* }}} */
28642868

Zend/zend_vm_def.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5119,7 +5119,7 @@ ZEND_VM_C_LABEL(num_index):
51195119
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
51205120
}
51215121

5122-
ZEND_VM_HANDLER(71, ZEND_INIT_ARRAY, CONST|TMP|VAR|UNUSED|CV, CONST|TMPVAR|UNUSED|NEXT|CV, ARRAY_INIT|REF)
5122+
ZEND_VM_HANDLER(71, ZEND_INIT_ARRAY, CONST|TMP|VAR|CV, CONST|TMPVAR|UNUSED|NEXT|CV, ARRAY_INIT|REF)
51235123
{
51245124
zval *array;
51255125
uint32_t size;
@@ -5141,13 +5141,7 @@ ZEND_VM_HANDLER(71, ZEND_INIT_ARRAY, CONST|TMP|VAR|UNUSED|CV, CONST|TMPVAR|UNUSE
51415141
}
51425142
}
51435143

5144-
if (OP1_TYPE == IS_UNUSED) {
5145-
ZEND_VM_NEXT_OPCODE();
5146-
#if !defined(ZEND_VM_SPEC) || (OP1_TYPE != IS_UNUSED)
5147-
} else {
5148-
ZEND_VM_DISPATCH_TO_HANDLER(ZEND_ADD_ARRAY_ELEMENT);
5149-
#endif
5150-
}
5144+
ZEND_VM_DISPATCH_TO_HANDLER(ZEND_ADD_ARRAY_ELEMENT);
51515145
}
51525146

51535147
ZEND_VM_HANDLER(21, ZEND_CAST, CONST|TMP|VAR|CV, ANY, TYPE)

0 commit comments

Comments
 (0)