Skip to content

Commit acfa564

Browse files
committed
Merge branch 'PHP-8.3'
* PHP-8.3: Fix bug #47925 again (#14348) Fix GH-14343: Memory leak in xml and dom (#14347)
2 parents e6abca4 + fe0214b commit acfa564

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

ext/dom/document.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,8 +785,13 @@ PHP_METHOD(DOMDocument, importNode)
785785
if (nsptr == NULL || nsptr->prefix == NULL) {
786786
int errorcode;
787787
nsptr = dom_get_ns(root, (char *) nodep->ns->href, &errorcode, (char *) nodep->ns->prefix);
788+
789+
/* If there is no root, the namespace cannot be attached to it, so we have to attach it to the old list. */
790+
if (nsptr != NULL && root == NULL) {
791+
dom_set_old_ns(nodep->doc, nsptr);
792+
}
788793
}
789-
xmlSetNs(retnodep, nsptr);
794+
retnodep->ns = nsptr;
790795
}
791796
}
792797

ext/dom/tests/gh14343.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
GH-14343 (Memory leak in xml and dom)
3+
--EXTENSIONS--
4+
dom
5+
--FILE--
6+
<?php
7+
$aDOM = new DOMDocument();
8+
$fromdom = new DOMDocument();
9+
$fromdom->loadXML('<data xmlns:ai="http://test.org" ai:attr="namespaced" />');
10+
$attr= $fromdom->firstChild->attributes->item(0);
11+
$att = $aDOM->importNode($attr);
12+
echo $aDOM->saveXML($att);
13+
?>
14+
--EXPECT--
15+
ai:attr="namespaced"

ext/soap/php_http.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,14 +1277,16 @@ int make_http_soap_request(zval *this_ptr,
12771277
zval retval;
12781278
zval params[1];
12791279

1280+
/* Warning: the zlib function names are chosen in an unfortunate manner.
1281+
* Check zlib.c to see how a function corresponds with a particular format. */
12801282
if ((strcmp(content_encoding,"gzip") == 0 ||
12811283
strcmp(content_encoding,"x-gzip") == 0) &&
1282-
zend_hash_str_exists(EG(function_table), "gzuncompress", sizeof("gzuncompress")-1)) {
1283-
ZVAL_STRING(&func, "gzuncompress");
1284+
zend_hash_str_exists(EG(function_table), "gzdecode", sizeof("gzdecode")-1)) {
1285+
ZVAL_STRING(&func, "gzdecode");
12841286
ZVAL_STR_COPY(&params[0], http_body);
12851287
} else if (strcmp(content_encoding,"deflate") == 0 &&
1286-
zend_hash_str_exists(EG(function_table), "gzinflate", sizeof("gzinflate")-1)) {
1287-
ZVAL_STRING(&func, "gzinflate");
1288+
zend_hash_str_exists(EG(function_table), "gzuncompress", sizeof("gzuncompress")-1)) {
1289+
ZVAL_STRING(&func, "gzuncompress");
12881290
ZVAL_STR_COPY(&params[0], http_body);
12891291
} else {
12901292
efree(content_encoding);

ext/soap/tests/bugs/bug47925.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ function test($compressed_response, $compression_name) {
3232
http_server_kill($pid);
3333
}
3434

35-
test(gzcompress($plain_response), "gzip");
36-
test(gzdeflate($plain_response), "deflate");
35+
test(gzencode($plain_response), "gzip");
36+
test(gzcompress($plain_response), "deflate");
3737
?>
3838
--EXPECT--
3939
int(7)

0 commit comments

Comments
 (0)