mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.3'
* PHP-8.3: Fix bug #47925 again (#14348) Fix GH-14343: Memory leak in xml and dom (#14347)
This commit is contained in:
@@ -785,8 +785,13 @@ PHP_METHOD(DOMDocument, importNode)
|
||||
if (nsptr == NULL || nsptr->prefix == NULL) {
|
||||
int errorcode;
|
||||
nsptr = dom_get_ns(root, (char *) nodep->ns->href, &errorcode, (char *) nodep->ns->prefix);
|
||||
|
||||
/* If there is no root, the namespace cannot be attached to it, so we have to attach it to the old list. */
|
||||
if (nsptr != NULL && root == NULL) {
|
||||
dom_set_old_ns(nodep->doc, nsptr);
|
||||
}
|
||||
}
|
||||
xmlSetNs(retnodep, nsptr);
|
||||
retnodep->ns = nsptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
15
ext/dom/tests/gh14343.phpt
Normal file
15
ext/dom/tests/gh14343.phpt
Normal file
@@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
GH-14343 (Memory leak in xml and dom)
|
||||
--EXTENSIONS--
|
||||
dom
|
||||
--FILE--
|
||||
<?php
|
||||
$aDOM = new DOMDocument();
|
||||
$fromdom = new DOMDocument();
|
||||
$fromdom->loadXML('<data xmlns:ai="http://test.org" ai:attr="namespaced" />');
|
||||
$attr= $fromdom->firstChild->attributes->item(0);
|
||||
$att = $aDOM->importNode($attr);
|
||||
echo $aDOM->saveXML($att);
|
||||
?>
|
||||
--EXPECT--
|
||||
ai:attr="namespaced"
|
||||
@@ -1277,14 +1277,16 @@ try_again:
|
||||
zval retval;
|
||||
zval params[1];
|
||||
|
||||
/* Warning: the zlib function names are chosen in an unfortunate manner.
|
||||
* Check zlib.c to see how a function corresponds with a particular format. */
|
||||
if ((strcmp(content_encoding,"gzip") == 0 ||
|
||||
strcmp(content_encoding,"x-gzip") == 0) &&
|
||||
zend_hash_str_exists(EG(function_table), "gzuncompress", sizeof("gzuncompress")-1)) {
|
||||
ZVAL_STRING(&func, "gzuncompress");
|
||||
zend_hash_str_exists(EG(function_table), "gzdecode", sizeof("gzdecode")-1)) {
|
||||
ZVAL_STRING(&func, "gzdecode");
|
||||
ZVAL_STR_COPY(¶ms[0], http_body);
|
||||
} else if (strcmp(content_encoding,"deflate") == 0 &&
|
||||
zend_hash_str_exists(EG(function_table), "gzinflate", sizeof("gzinflate")-1)) {
|
||||
ZVAL_STRING(&func, "gzinflate");
|
||||
zend_hash_str_exists(EG(function_table), "gzuncompress", sizeof("gzuncompress")-1)) {
|
||||
ZVAL_STRING(&func, "gzuncompress");
|
||||
ZVAL_STR_COPY(¶ms[0], http_body);
|
||||
} else {
|
||||
efree(content_encoding);
|
||||
|
||||
@@ -32,8 +32,8 @@ function test($compressed_response, $compression_name) {
|
||||
http_server_kill($pid);
|
||||
}
|
||||
|
||||
test(gzcompress($plain_response), "gzip");
|
||||
test(gzdeflate($plain_response), "deflate");
|
||||
test(gzencode($plain_response), "gzip");
|
||||
test(gzcompress($plain_response), "deflate");
|
||||
?>
|
||||
--EXPECT--
|
||||
int(7)
|
||||
|
||||
Reference in New Issue
Block a user