From e36daa6927c05d2e687bb77495ef206cde118b33 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Wed, 25 Dec 2019 15:55:15 +0800 Subject: Fixed bug #79029 (Use After Free's in XMLReader / XMLWriter). --- ext/libxml/libxml.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'ext/libxml/libxml.c') diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index efccf0a407..333dab4856 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -355,6 +355,10 @@ static void *php_libxml_streams_IO_open_wrapper(const char *filename, const char context = php_stream_context_from_zval(Z_ISUNDEF(LIBXML(stream_context))? NULL : &LIBXML(stream_context), 0); ret_val = php_stream_open_wrapper_ex(path_to_open, (char *)mode, REPORT_ERRORS, NULL, context); + if (ret_val) { + /* Prevent from closing this by fclose() */ + ((php_stream*)ret_val)->flags |= PHP_STREAM_FLAG_NO_FCLOSE; + } if (isescaped) { xmlFree(resolved_path); } -- cgit v1.2.1