Skip to content

Commit d239f81

Browse files
committed
Merge branch 'master' into jit-dynasm
* master: (27 commits) Fix assertion in Exception::getMessage() if $message is a ref Fix some directory collisions in dir tests Fix some port collisions in sockets tests Fixed compiler warning Update NEWS Fixed bug #77660 (Segmentation fault on break 2147483648) Update NEWS Fixed bug #77664 (Segmentation fault when using undefined constant in custom wrapper) Revert "Disable bug77390.phpt" Print empty string in test for but 77390 just once Use spaces instead of tabs in bug 77390 test Remove unused PHP_AC_BROKEN_SPRINTF and AC_ZEND_BROKEN_SPRINTF Replace Hebrew characters with escape sequences Disable bug77390.phpt Fix anon class handling in ext mode Remove result def during jmp_set optimization Fix removal of unreachable code in SCCP Fix inference warning about missing key type Fix get_unresolved_initializer for static props Fix directory collisions in zlib tests ...
2 parents 5466d2d + d5ff574 commit d239f81

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+458
-519
lines changed

TSRM/tsrm_win32.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -468,17 +468,17 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd,
468468
return NULL;
469469
}
470470

471-
/*The following two checks can be removed once we drop XP support */
472471
type_len = (int)strlen(type);
473-
if (type_len <1 || type_len > 2) {
472+
if (type_len < 1 || type_len > 2) {
474473
return NULL;
475474
}
476475

477-
for (i=0; i < type_len; i++) {
478-
if (!(*ptype == 'r' || *ptype == 'w' || *ptype == 'b' || *ptype == 't')) {
479-
return NULL;
480-
}
481-
ptype++;
476+
if (ptype[0] != 'r' && ptype[0] != 'w') {
477+
return NULL;
478+
}
479+
480+
if (type_len > 1 && (ptype[1] != 'b' && ptype[1] != 't')) {
481+
return NULL;
482482
}
483483

484484
cmd = (char*)malloc(strlen(command)+strlen(TWG(comspec))+sizeof(" /c ")+2);

Zend/Zend.m4

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ LIBZEND_CHECK_INT_TYPE(uint32_t)
8080
dnl Checks for library functions.
8181
AC_FUNC_ALLOCA
8282
AC_CHECK_FUNCS(memcpy strdup getpid kill strtod strtol finite fpclass sigsetjmp)
83-
AC_ZEND_BROKEN_SPRINTF
8483
8584
AC_CHECK_DECLS([isfinite, isnan, isinf], [], [], [[#include <math.h>]])
8685

Zend/acinclude.m4

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,27 +58,6 @@ fp_except x = (fp_except) 0;
5858
fi
5959
])
6060

61-
dnl
62-
dnl Check for broken sprintf()
63-
dnl
64-
AC_DEFUN([AC_ZEND_BROKEN_SPRINTF],[
65-
AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[
66-
AC_RUN_IFELSE([AC_LANG_SOURCE([[main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }]])],[
67-
ac_cv_broken_sprintf=no
68-
],[
69-
ac_cv_broken_sprintf=yes
70-
],[
71-
ac_cv_broken_sprintf=no
72-
])
73-
])
74-
if test "$ac_cv_broken_sprintf" = "yes"; then
75-
ac_result=1
76-
else
77-
ac_result=0
78-
fi
79-
AC_DEFINE_UNQUOTED(ZEND_BROKEN_SPRINTF, $ac_result, [Whether sprintf is broken])
80-
])
81-
8261
dnl x87 floating point internal precision control checks
8362
dnl See: http://wiki.php.net/rfc/rounding
8463
AC_DEFUN([ZEND_CHECK_FLOAT_PRECISION],[

Zend/tests/bug77652.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
return [
3+
'I' => function() {
4+
return new class implements I {};
5+
},
6+
];

Zend/tests/bug77652.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug #77652: Anonymous classes can lose their interface information
3+
--FILE--
4+
<?php
5+
6+
interface I {}
7+
require __DIR__ . '/bug77652.inc';
8+
$data = require __DIR__ . '/bug77652.inc';
9+
print_r(class_implements($data['I']()));
10+
11+
?>
12+
--EXPECT--
13+
Array
14+
(
15+
[I] => I
16+
)

Zend/tests/bug77660.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Bug #77660 (Segmentation fault on break 2147483648)
3+
--SKIPIF--
4+
<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?>
5+
--FILE--
6+
<?php
7+
for(;;) break 2147483648;
8+
?>
9+
--EXPECTF--
10+
Fatal error: Cannot 'break' 2147483648 levels in %sbug77660.php on line %d
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Calling exception getters when properties hold references
3+
--FILE--
4+
<?php
5+
6+
class MyException extends Exception {
7+
public function __construct(&$refMsg, &$refCode, &$refFile, &$refLine) {
8+
$this->message =& $refMsg;
9+
$this->code =& $refCode;
10+
$this->file =& $refFile;
11+
$this->line =& $refLine;
12+
}
13+
}
14+
15+
$refMsg = "foo";
16+
$refCode = 0;
17+
$refFile = "foobar";
18+
$refLine = 42;
19+
$ex = new MyException($refMsg, $refCode, $refFile, $refLine);
20+
var_dump($ex->getMessage());
21+
var_dump($ex->getCode());
22+
var_dump($ex->getFile());
23+
var_dump($ex->getLine());
24+
25+
?>
26+
--EXPECT--
27+
string(3) "foo"
28+
int(0)
29+
string(6) "foobar"
30+
int(42)

Zend/zend.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
#include "zend_smart_string_public.h"
4141
#include "zend_signal.h"
4242

43+
#define zend_sprintf sprintf
44+
4345
#define HANDLE_BLOCK_INTERRUPTIONS() ZEND_SIGNAL_BLOCK_INTERRUPTIONS()
4446
#define HANDLE_UNBLOCK_INTERRUPTIONS() ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS()
4547

Zend/zend_compile.c

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static zend_string *zend_build_runtime_definition_key(zend_string *name, unsigne
131131
{
132132
zend_string *result;
133133
char char_pos_buf[32];
134-
size_t char_pos_len = zend_sprintf(char_pos_buf, "%p", lex_pos);
134+
size_t char_pos_len = sprintf(char_pos_buf, "%p", lex_pos);
135135
zend_string *filename = CG(active_op_array)->filename;
136136

137137
/* NULL, name length, filename length, last accepting char position length */
@@ -3941,7 +3941,7 @@ void zend_compile_static_call(znode *result, zend_ast *ast, uint32_t type) /* {{
39413941
}
39423942
/* }}} */
39433943

3944-
void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel);
3944+
zend_op *zend_compile_class_decl(zend_ast *ast, zend_bool toplevel);
39453945

39463946
void zend_compile_new(znode *result, zend_ast *ast) /* {{{ */
39473947
{
@@ -3952,13 +3952,8 @@ void zend_compile_new(znode *result, zend_ast *ast) /* {{{ */
39523952
zend_op *opline;
39533953

39543954
if (class_ast->kind == ZEND_AST_CLASS) {
3955-
uint32_t dcl_opnum = get_next_op_number();
3956-
zend_compile_class_decl(class_ast, 0);
39573955
/* jump over anon class declaration */
3958-
opline = &CG(active_op_array)->opcodes[dcl_opnum];
3959-
if (opline->opcode == ZEND_FETCH_CLASS) {
3960-
opline++;
3961-
}
3956+
opline = zend_compile_class_decl(class_ast, 0);
39623957
class_node.op_type = opline->result_type;
39633958
class_node.u.op.var = opline->result.var;
39643959
opline->extended_value = get_next_op_number();
@@ -4277,7 +4272,7 @@ void zend_compile_break_continue(zend_ast *ast) /* {{{ */
42774272
zend_ast *depth_ast = ast->child[0];
42784273

42794274
zend_op *opline;
4280-
int depth;
4275+
zend_long depth;
42814276

42824277
ZEND_ASSERT(ast->kind == ZEND_AST_BREAK || ast->kind == ZEND_AST_CONTINUE);
42834278

@@ -4304,7 +4299,7 @@ void zend_compile_break_continue(zend_ast *ast) /* {{{ */
43044299
ast->kind == ZEND_AST_BREAK ? "break" : "continue");
43054300
} else {
43064301
if (!zend_handle_loops_and_finally_ex(depth, NULL)) {
4307-
zend_error_noreturn(E_COMPILE_ERROR, "Cannot '%s' %d level%s",
4302+
zend_error_noreturn(E_COMPILE_ERROR, "Cannot '%s' " ZEND_LONG_FMT " level%s",
43084303
ast->kind == ZEND_AST_BREAK ? "break" : "continue",
43094304
depth, depth == 1 ? "" : "s");
43104305
}
@@ -4321,12 +4316,12 @@ void zend_compile_break_continue(zend_ast *ast) /* {{{ */
43214316
if (depth == 1) {
43224317
zend_error(E_WARNING,
43234318
"\"continue\" targeting switch is equivalent to \"break\". " \
4324-
"Did you mean to use \"continue %d\"?",
4319+
"Did you mean to use \"continue " ZEND_LONG_FMT "\"?",
43254320
depth + 1);
43264321
} else {
43274322
zend_error(E_WARNING,
4328-
"\"continue %d\" targeting switch is equivalent to \"break %d\". " \
4329-
"Did you mean to use \"continue %d\"?",
4323+
"\"continue " ZEND_LONG_FMT "\" targeting switch is equivalent to \"break " ZEND_LONG_FMT "\". " \
4324+
"Did you mean to use \"continue " ZEND_LONG_FMT "\"?",
43304325
depth, depth, depth + 1);
43314326
}
43324327
}
@@ -6126,7 +6121,7 @@ static zend_string *zend_generate_anon_class_name(unsigned char *lex_pos) /* {{{
61266121
{
61276122
zend_string *result;
61286123
char char_pos_buf[32];
6129-
size_t char_pos_len = zend_sprintf(char_pos_buf, "%p", lex_pos);
6124+
size_t char_pos_len = sprintf(char_pos_buf, "%p", lex_pos);
61306125
zend_string *filename = CG(active_op_array)->filename;
61316126

61326127
/* NULL, name length, filename length, last accepting char position length */
@@ -6136,7 +6131,7 @@ static zend_string *zend_generate_anon_class_name(unsigned char *lex_pos) /* {{{
61366131
}
61376132
/* }}} */
61386133

6139-
void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
6134+
zend_op *zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
61406135
{
61416136
zend_ast_decl *decl = (zend_ast_decl *) ast;
61426137
zend_ast *extends_ast = decl->child[0];
@@ -6291,15 +6286,15 @@ void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
62916286
}
62926287
CG(zend_lineno) = ast->lineno;
62936288
zend_string_release(lcname);
6294-
return;
6289+
return NULL;
62956290
}
62966291
}
62976292
} else {
62986293
if (EXPECTED(zend_hash_add_ptr(CG(class_table), lcname, ce) != NULL)) {
62996294
zend_string_release(lcname);
63006295
zend_build_properties_info_table(ce);
63016296
ce->ce_flags |= ZEND_ACC_LINKED;
6302-
return;
6297+
return NULL;
63036298
}
63046299
}
63056300
}
@@ -6325,7 +6320,7 @@ void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
63256320
zval zv;
63266321
ZVAL_PTR(&zv, ce);
63276322
destroy_zend_class(&zv);
6328-
return;
6323+
return opline;
63296324
}
63306325
} else {
63316326
zend_string *key = zend_build_runtime_definition_key(lcname, decl->lex_pos);
@@ -6352,6 +6347,7 @@ void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
63526347
opline->opcode = ZEND_DECLARE_CLASS;
63536348
}
63546349
}
6350+
return opline;
63556351
}
63566352
/* }}} */
63576353

Zend/zend_config.w32.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ extern "C++" {
6363
#define zend_isnan(x) _isnan(x)
6464
#endif
6565

66-
#define zend_sprintf sprintf
67-
6866
#ifndef __cplusplus
6967
/* This will cause the compilation process to be MUCH longer, but will generate
7068
* a much quicker PHP binary

0 commit comments

Comments
 (0)