summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-02-13 15:13:26 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2020-02-13 15:13:26 +0100
commitcec8b24c848bab8562c82422f3692c193f0afcdb (patch)
tree6f1cf42a07d70b49982e6f512357df6a604d0a86
parent2dc170e25d86a725fefd4c08f2bd8378820b28f5 (diff)
downloadphp-git-cec8b24c848bab8562c82422f3692c193f0afcdb.tar.gz
Fix #77569: Write Acess Violation in DomImplementation
We must not assume that the zval IS_STRING.
-rw-r--r--NEWS3
-rw-r--r--ext/dom/document.c2
-rw-r--r--ext/dom/tests/bug77569.phpt14
3 files changed, 18 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index a38b23225d..672ce05405 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2020, PHP 7.2.28
+- DOM:
+ . Fixed bug #77569: (Write Acess Violation in DomImplementation). (Nikita,
+ cmb)
23 Jan 2020, PHP 7.2.27
diff --git a/ext/dom/document.c b/ext/dom/document.c
index c9e1802f78..11ef4aa818 100644
--- a/ext/dom/document.c
+++ b/ext/dom/document.c
@@ -341,7 +341,7 @@ int dom_document_encoding_write(dom_object *obj, zval *newval)
str = zval_get_string(newval);
- handler = xmlFindCharEncodingHandler(Z_STRVAL_P(newval));
+ handler = xmlFindCharEncodingHandler(ZSTR_VAL(str));
if (handler != NULL) {
xmlCharEncCloseFunc(handler);
diff --git a/ext/dom/tests/bug77569.phpt b/ext/dom/tests/bug77569.phpt
new file mode 100644
index 0000000000..f0f3566708
--- /dev/null
+++ b/ext/dom/tests/bug77569.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #77569 (Write Acess Violation in DomImplementation)
+--SKIPIF--
+<?php
+if (!extension_loaded('dom')) die('skip dom extension not available');
+?>
+--FILE--
+<?php
+$imp = new DOMImplementation;
+$dom = $imp->createDocument("", "");
+$dom->encoding = null;
+?>
+--EXPECTF--
+Warning: main(): Invalid Document Encoding in %s on line %d