|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34150 xml_set_element_handler segfaults using object in callback
Submitted: 2005-08-16 12:00 UTC Modified: 2005-08-18 04:14 UTC
From: pierre at dotgeek dot org Assigned:
Status: Not a bug Package: XML related
PHP Version: 4CVS-2005-08-16 (CVS) OS: linux
Private report: No CVE-ID: None
 [2005-08-16 12:00 UTC] pierre at dotgeek dot org
xml_set_element_handler segfaults when using a reference to an object or "this" using 4.4 cvs or stock release.

Reproduce code:

class parser {
        var $parser = NULL;
        var $stack = '';

        function parser() {
                $this->parser = xml_parser_create();
                xml_set_element_handler($this->parser, array(&$this, '_startElement'), array(&$this, '_endElement'));

        function _startElement($parser, $tag) {
                $this->stack .= $tag . '/';


        function _endElement($parser, $tag) {
                $this->stack .= $tag . '/';

$parser = new parser();

Expected result:
no segfault.

Actual result:
Non debug mode ends with:
*** glibc detected *** ./sapi/cli/php: double free or corruption (!prev): 0x0a1a76b0 ***
======= Backtrace: =========

I can provide a backtrace later if required but the script is here :)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-16 21:32 UTC]
Which libxml2 version are you using? (No idea, if it's 
related, just to be sure...)
 [2005-08-17 08:13 UTC]
I can reproduce it now.. No idea, where exactly the problem is 
(and no intention to fix it, as I have not much of an idea of 
that part of the code)
 [2005-08-18 04:14 UTC]
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

duplicate of Bug #32494
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 05 13:01:33 2024 UTC