summaryrefslogtreecommitdiff
path: root/ext/reflection/php_reflection.h
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-08-10 10:40:31 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2020-08-10 12:23:44 +0200
commit0af3f493121f8eb5f71051303c5ee1a42a81fc6f (patch)
treeefd307aa7d82397faf96300a748b6ba3e6f6671c /ext/reflection/php_reflection.h
parent5be670265b261f2c0162ba89827f5652ba584b05 (diff)
downloadphp-git-0af3f493121f8eb5f71051303c5ee1a42a81fc6f.tar.gz
Fix #79922: Crash after multiple calls to xml_parser_free()
We must not call `zend_list_delete()` in resource closer functions exposed to userland, because decreasing the refcount there leads to use-after-free scenarios. In this case, commit 4a42fbb worked for typical use-cases where `xml_parser_free()` has been called exactly once for the resource, because there is an internal zval (`->index`) referencing the same resource which already increased the refcount by one. However, when `xml_parser_free()` is called multiple times on the same XML parser resource, the resource would be freed prematurely. Instead we forcefully close the resource in `xml_parser_free()`. We also could decrease the refcount of the resource there, but that would require to call `xml_parser_free()` which is somewhat uncommon, and would be particularly bad wrt. PHP 8 where that function is a NOP, and as such doesn't have to be called. So we do no longer increase the refcount of the resource when copying it to the internal zval, and let the usualy refcounting semantics take care of the resource destruction. [1] <http://git.php.net/?p=php-src.git;a=commit;h=4a42fbbbc73aad7427aef5c89974d1833636e082>
Diffstat (limited to 'ext/reflection/php_reflection.h')
0 files changed, 0 insertions, 0 deletions