Skip to content

Commit 58df9fc

Browse files
committed
Fix UAF in tidy when tidySetErrorBuffer() fails
We should not free `intern` as its stored in the object store as well, so the object store will already free it, leading to a UAF when the object store tries to read the object's fields. Closes phpGH-20276.
1 parent c7fc819 commit 58df9fc

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

NEWS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ PHP NEWS
7474
. Fixed bug GH-19798: XP_SOCKET XP_SSL (Socket stream modules): Incorrect
7575
condition for Win32/Win64. (Jakub Zelenka)
7676

77-
7877
- Tidy:
7978
. Fixed GH-19021 (improved tidyOptGetCategory detection).
8079
(arjendekorte, David Carlier, Peter Kokot)
80+
. Fix UAF in tidy when tidySetErrorBuffer() fails. (nielsdos)
8181

8282
- XMLReader:
8383
. Fix arginfo/zpp violations when LIBXML_SCHEMAS_ENABLED is not available.

ext/tidy/tidy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ static zend_object *tidy_object_new(zend_class_entry *class_type, zend_object_ha
434434
efree(intern->ptdoc->errbuf);
435435
tidyRelease(intern->ptdoc->doc);
436436
efree(intern->ptdoc);
437-
efree(intern);
437+
/* TODO: convert to exception */
438438
php_error_docref(NULL, E_ERROR, "Could not set Tidy error buffer");
439439
}
440440

0 commit comments

Comments
 (0)