Skip to content

Commit 24328ac

Browse files
committed
Merge branch 'master' into assert
* master: Fixed C++ support Fixed bug #69115 crash in mail Reorder Update NEWs Fixed bug #69121 (Segfault in get_current_user when script owner is not in passwd with ZTS build) Update News Fixed bug #69125 (Array numeric string as key) fix bug#68942's patch Fixed ability to build unspecialized executor Fixed bug #69124 (method name could not be used when by ref) Fixed a bug that header value is not terminated by '\0' when accessed through getenv(). Fixed a bug that header value is not terminated by '\0' when accessed through getenv().
2 parents 021fd94 + 1cdee9a commit 24328ac

File tree

12 files changed

+242
-113
lines changed

12 files changed

+242
-113
lines changed

Zend/tests/bug69124.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug 69124: Method name must be as string (invalid error message when using reference to a string)
3+
--FILE--
4+
<?php
5+
class Foo {
6+
public function bar() {
7+
print "Success\n";
8+
}
9+
}
10+
11+
function test(&$instance, &$method) {
12+
$instance->{$method}();
13+
}
14+
15+
$instance = new Foo;
16+
$method = "bar";
17+
18+
test($instance, $method);
19+
?>
20+
--EXPECT--
21+
Success

Zend/zend_operators.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ ZEND_API zend_uchar _is_numeric_string_ex(const char *str, size_t length, zend_l
9090
ZEND_API const char* zend_memnstr_ex(const char *haystack, const char *needle, size_t needle_len, char *end);
9191
ZEND_API const char* zend_memnrstr_ex(const char *haystack, const char *needle, size_t needle_len, char *end);
9292

93-
END_EXTERN_C()
94-
9593
#if SIZEOF_ZEND_LONG == 4
9694
# define ZEND_DOUBLE_FITS_LONG(d) (!((d) > ZEND_LONG_MAX || (d) < ZEND_LONG_MIN))
9795
#else
@@ -234,7 +232,6 @@ zend_memnrstr(const char *haystack, const char *needle, size_t needle_len, char
234232
}
235233
}
236234

237-
BEGIN_EXTERN_C()
238235
ZEND_API int increment_function(zval *op1);
239236
ZEND_API int decrement_function(zval *op2);
240237

Zend/zend_vm_def.h

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,14 +1659,13 @@ ZEND_VM_HANDLER(98, ZEND_FETCH_LIST, CONST|TMPVAR|CV, CONST)
16591659

16601660
ZEND_VM_C_LABEL(try_fetch_list):
16611661
if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
1662-
zend_free_op free_op2;
1663-
zval *value = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE, BP_VAR_R);
1662+
zval *value = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), EX_CONSTANT(opline->op2), OP2_TYPE, BP_VAR_R);
16641663

16651664
ZVAL_COPY(EX_VAR(opline->result.var), value);
16661665
} else if (UNEXPECTED(Z_TYPE_P(container) == IS_OBJECT) &&
16671666
EXPECTED(Z_OBJ_HT_P(container)->read_dimension)) {
16681667
zval *result = EX_VAR(opline->result.var);
1669-
zval *retval = Z_OBJ_HT_P(container)->read_dimension(container, GET_OP2_ZVAL_PTR(BP_VAR_R), BP_VAR_R, result);
1668+
zval *retval = Z_OBJ_HT_P(container)->read_dimension(container, EX_CONSTANT(opline->op2), BP_VAR_R, result);
16701669

16711670
if (retval) {
16721671
if (result != retval) {
@@ -2336,12 +2335,19 @@ ZEND_VM_HANDLER(112, ZEND_INIT_METHOD_CALL, TMPVAR|UNUSED|CV, CONST|TMPVAR|CV)
23362335

23372336
function_name = GET_OP2_ZVAL_PTR(BP_VAR_R);
23382337

2339-
if (OP2_TYPE != IS_CONST &&
2340-
UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) {
2341-
if (UNEXPECTED(EG(exception) != NULL)) {
2342-
HANDLE_EXCEPTION();
2343-
}
2344-
zend_error_noreturn(E_ERROR, "Method name must be a string");
2338+
if (OP2_TYPE != IS_CONST && UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) {
2339+
do {
2340+
if ((OP2_TYPE & (IS_VAR|IS_CV)) && Z_ISREF_P(function_name)) {
2341+
function_name = Z_REFVAL_P(function_name);
2342+
if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
2343+
break;
2344+
}
2345+
}
2346+
if (UNEXPECTED(EG(exception) != NULL)) {
2347+
HANDLE_EXCEPTION();
2348+
}
2349+
zend_error_noreturn(E_ERROR, "Method name must be a string");
2350+
} while (0);
23452351
}
23462352

23472353
object = GET_OP1_OBJ_ZVAL_PTR(BP_VAR_R);
@@ -3198,7 +3204,7 @@ ZEND_VM_C_LABEL(fcall_end):
31983204

31993205
ZEND_VM_HANDLER(124, ZEND_VERIFY_RETURN_TYPE, CONST|TMP|VAR|UNUSED|CV, UNUSED)
32003206
{
3201-
#if OP1_TYPE != IS_UNUSED
3207+
#if !defined(ZEND_VM_SPEC) || (OP1_TYPE != IS_UNUSED)
32023208
USE_OPLINE
32033209
#endif
32043210
SAVE_OPLINE();
@@ -4443,7 +4449,7 @@ ZEND_VM_HANDLER(71, ZEND_INIT_ARRAY, CONST|TMP|VAR|UNUSED|CV, CONST|TMPVAR|UNUSE
44434449

44444450
if (OP1_TYPE == IS_UNUSED) {
44454451
ZEND_VM_NEXT_OPCODE();
4446-
#if !defined(ZEND_VM_SPEC) || OP1_TYPE != IS_UNUSED
4452+
#if !defined(ZEND_VM_SPEC) || (OP1_TYPE != IS_UNUSED)
44474453
} else {
44484454
ZEND_VM_DISPATCH_TO_HANDLER(ZEND_ADD_ARRAY_ELEMENT);
44494455
#endif

0 commit comments

Comments
 (0)