Skip to content

Commit cec8b24

Browse files
committed
Fix #77569: Write Acess Violation in DomImplementation
We must not assume that the zval IS_STRING.
1 parent 2dc170e commit cec8b24

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2020, PHP 7.2.28
44

5+
- DOM:
6+
. Fixed bug #77569: (Write Acess Violation in DomImplementation). (Nikita,
7+
cmb)
58

69
23 Jan 2020, PHP 7.2.27
710

ext/dom/document.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ int dom_document_encoding_write(dom_object *obj, zval *newval)
341341

342342
str = zval_get_string(newval);
343343

344-
handler = xmlFindCharEncodingHandler(Z_STRVAL_P(newval));
344+
handler = xmlFindCharEncodingHandler(ZSTR_VAL(str));
345345

346346
if (handler != NULL) {
347347
xmlCharEncCloseFunc(handler);

ext/dom/tests/bug77569.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Bug #77569 (Write Acess Violation in DomImplementation)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('dom')) die('skip dom extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
$imp = new DOMImplementation;
10+
$dom = $imp->createDocument("", "");
11+
$dom->encoding = null;
12+
?>
13+
--EXPECTF--
14+
Warning: main(): Invalid Document Encoding in %s on line %d

0 commit comments

Comments
 (0)