Skip to content

Commit 9c9c0b8

Browse files
authored
Merge branch 'php:master' into parameter-doccomments
2 parents b2c92ad + 87b8345 commit 9c9c0b8

6 files changed

Lines changed: 57 additions & 15 deletions

File tree

Zend/tests/gh21504.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
'1234' |> var_dump(...);

Zend/tests/gh21504.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
GH-21504: Incorrect RC-handling for ZEND_EXT_STMT op1
3+
--FILE--
4+
<?php
5+
6+
$php_escaped = getenv('TEST_PHP_EXECUTABLE_ESCAPED');
7+
$cmd = $php_escaped . ' -n -e ' . escapeshellarg(__DIR__ . '/gh21504.inc');
8+
echo shell_exec($cmd);
9+
10+
?>
11+
--EXPECT--
12+
string(4) "1234"

Zend/zend_compile.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,6 +1950,9 @@ static void zend_do_extended_stmt(znode* result) /* {{{ */
19501950

19511951
opline->opcode = ZEND_EXT_STMT;
19521952
if (result) {
1953+
if (result->op_type == IS_CONST) {
1954+
Z_TRY_ADDREF(result->u.constant);
1955+
}
19531956
SET_NODE(opline->op1, result);
19541957
}
19551958
}

ext/dom/node.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2132,7 +2132,7 @@ static void dom_relink_ns_decls_element(HashTable *links, xmlNodePtr node)
21322132

21332133
ns->_private = attr;
21342134
if (attr->prev) {
2135-
attr->prev = attr->next;
2135+
attr->prev->next = attr->next;
21362136
} else {
21372137
node->properties = attr->next;
21382138
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
GH-21548 (Dom\XMLDocument::C14N() emits duplicate xmlns declarations after setAttributeNS())
3+
--CREDITS--
4+
Toon Verwerft (veewee)
5+
--EXTENSIONS--
6+
dom
7+
--FILE--
8+
<?php
9+
10+
$doc = Dom\XMLDocument::createFromString('<root xmlns="urn:a" attr="val"/>');
11+
$doc->documentElement->setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:ns1", "urn:a");
12+
13+
echo $doc->C14N() . PHP_EOL;
14+
15+
?>
16+
--EXPECT--
17+
<root xmlns="urn:a" xmlns:ns1="urn:a" attr="val"></root>

sapi/phpdbg/phpdbg_prompt.c

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,32 +1188,39 @@ static void add_zendext_info(zend_extension *ext) /* {{{ */ {
11881188
/* }}} */
11891189

11901190
#ifdef HAVE_LIBDL
1191-
PHPDBG_API const char *phpdbg_load_module_or_extension(char **path, const char **name) /* {{{ */ {
1191+
static const char *phpdbg_load_module_or_extension(zend_string **path, const char **name) /* {{{ */ {
11921192
DL_HANDLE handle;
1193-
zend_string *extension_dir = zend_ini_str_literal("extension_dir");
1193+
const zend_string *extension_dir = zend_ini_str_literal("extension_dir");
11941194

11951195
if (UNEXPECTED(zend_str_has_nul_byte(extension_dir))) {
11961196
phpdbg_error("extension_dir ini setting contains a nul byte");
11971197
return NULL;
11981198
}
1199-
if (strchr(*path, '/') != NULL || strchr(*path, DEFAULT_SLASH) != NULL) {
1199+
if (memchr(ZSTR_VAL(*path), '/', ZSTR_LEN(*path)) != NULL || memchr(ZSTR_VAL(*path), '/', ZSTR_LEN(*path)) != NULL) {
12001200
/* path is fine */
12011201
} else if (extension_dir && ZSTR_LEN(extension_dir) > 0) {
1202-
char *libpath;
1202+
zend_string *libpath;
12031203
if (IS_SLASH(ZSTR_VAL(extension_dir)[ZSTR_LEN(extension_dir)-1])) {
1204-
spprintf(&libpath, 0, "%s%s", ZSTR_VAL(extension_dir), *path); /* SAFE */
1204+
libpath = zend_string_concat2(
1205+
ZSTR_VAL(extension_dir), ZSTR_LEN(extension_dir),
1206+
ZSTR_VAL(*path), ZSTR_LEN(*path)
1207+
);
12051208
} else {
1206-
spprintf(&libpath, 0, "%s%c%s", ZSTR_VAL(extension_dir), DEFAULT_SLASH, *path); /* SAFE */
1209+
libpath = zend_string_concat3(
1210+
ZSTR_VAL(extension_dir), ZSTR_LEN(extension_dir),
1211+
"/", 1,
1212+
ZSTR_VAL(*path), ZSTR_LEN(*path)
1213+
);
12071214
}
1208-
efree(*path);
1215+
zend_string_release_ex(*path, false);
12091216
*path = libpath;
12101217
} else {
12111218
phpdbg_error("Not a full path given or extension_dir ini setting is not set");
12121219

12131220
return NULL;
12141221
}
12151222

1216-
handle = DL_LOAD(*path);
1223+
handle = DL_LOAD(ZSTR_VAL(*path));
12171224

12181225
if (!handle) {
12191226
#ifdef PHP_WIN32
@@ -1331,7 +1338,6 @@ PHPDBG_API const char *phpdbg_load_module_or_extension(char **path, const char *
13311338
PHPDBG_COMMAND(dl) /* {{{ */
13321339
{
13331340
const char *type, *name;
1334-
char *path;
13351341

13361342
if (!param || param->type == EMPTY_PARAM) {
13371343
phpdbg_notice("Zend extensions");
@@ -1340,23 +1346,24 @@ PHPDBG_COMMAND(dl) /* {{{ */
13401346
phpdbg_notice("Modules");
13411347
zend_hash_apply(&module_registry, (apply_func_t) add_module_info);
13421348
} else switch (param->type) {
1343-
case STR_PARAM:
1349+
case STR_PARAM: {
13441350
#ifdef HAVE_LIBDL
1345-
path = estrndup(param->str, param->len);
1351+
zend_string *path = zend_string_init(param->str, param->len, false);
13461352

13471353
phpdbg_activate_err_buf(1);
13481354
if ((type = phpdbg_load_module_or_extension(&path, &name)) == NULL) {
1349-
phpdbg_error("Could not load %s, not found or invalid zend extension / module: %s", path, PHPDBG_G(err_buf).msg);
1355+
phpdbg_error("Could not load %s, not found or invalid zend extension / module: %s", ZSTR_VAL(path), PHPDBG_G(err_buf).msg);
13501356
} else {
1351-
phpdbg_notice("Successfully loaded the %s %s at path %s", type, name, path);
1357+
phpdbg_notice("Successfully loaded the %s %s at path %s", type, name, ZSTR_VAL(path));
13521358
}
13531359
phpdbg_activate_err_buf(0);
13541360
phpdbg_free_err_buf();
1355-
efree(path);
1361+
zend_string_release_ex(path, false);
13561362
#else
13571363
phpdbg_error("Cannot dynamically load %.*s - dynamic modules are not supported", (int) param->len, param->str);
13581364
#endif
13591365
break;
1366+
}
13601367

13611368
phpdbg_default_switch_case();
13621369
}

0 commit comments

Comments
 (0)