From fe1bfb78d65d28dd151da417477a0cee51de8afb Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Mon, 3 Feb 2020 23:10:20 +0100 Subject: Fix #79191: Error in SoapClient ctor disables DOMDocument::save() The culprit is the too restrictive fix for bug #71536, which prevents `php_libxml_streams_IO_write()` from properly executing when unclean shutdown is flagged. A *more* suitable solution is to move the `xmlwriter_free_resource_ptr()` call from the `free_obj` handler to an added `dtor_obj` handler, to avoid to write to a closed stream in case of late object freeing. This makes the `EG(active)` guard superfluous. We also fix bug79029.phpt which has to use different variables for the three parts to actually check the original shutdown issue. Thanks to bwoebi and daverandom for helping to investigate this issue. --- ext/libxml/libxml.c | 3 --- ext/libxml/tests/bug79191.phpt | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 ext/libxml/tests/bug79191.phpt (limited to 'ext/libxml') diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index 864e5a36fb..2be6a5b47a 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -385,9 +385,6 @@ static int php_libxml_streams_IO_read(void *context, char *buffer, int len) static int php_libxml_streams_IO_write(void *context, const char *buffer, int len) { - if (CG(unclean_shutdown)) { - return -1; - } return php_stream_write((php_stream*)context, buffer, len); } diff --git a/ext/libxml/tests/bug79191.phpt b/ext/libxml/tests/bug79191.phpt new file mode 100644 index 0000000000..7d0dc83f23 --- /dev/null +++ b/ext/libxml/tests/bug79191.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #79191 (Error in SoapClient ctor disables DOMDocument::save()) +--SKIPIF-- + +--FILE-- +loadxml(''); +var_dump($dom->save(__DIR__ . '/bug79191.xml')); +?> +--CLEAN-- + +--EXPECTF-- +int(%d) -- cgit v1.2.1