php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10254 xml_set_object() and segmentation fault
Submitted: 2001-04-09 18:06 UTC Modified: 2002-02-19 00:00 UTC
From: mnino at insight dot com Assigned:
Status: No Feedback Package: XML related
PHP Version: 4.0.4pl1 OS: Redhat 6.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
40 - 2 = ?
Subscribe to this entry?

 
 [2001-04-09 18:06 UTC] mnino at insight dot com
I am receiving "segmentation fault" when using xml_set_object() and setting handlers in the constructor. I moved them to the parse() method and the crashes stop. I found the resolution for a similiar issue in the feedback thread at the end of xml_set_object() documentation just in case you guys are already aware of this issue : )

Feedback Thread
===============
williams@cse.unl.edu
06-Dec-2000 12:42 
If xml_set_object is not called in the constructor of an object, the values that the parser modifies will be saved. Else, the values do not seem to be saved as stated by "i_sofer" above. 
--- Start Example Code --- 
class foo { 
var xmlparser; 
function foo() { \\the constructor 
$this->xmlparser=xmlparser_create(); 
} 
function parse() { 
xml_set_object($this->xmlparser,&$this); 
\\also include data handler 
\\and element handlers here 
} 
} 
--- End Example Code --- 


My Code
=======

function parse($data) {
    $this->parser = xml_parser_create();
    xml_set_object($this->parser,&$this);
    xml_set_element_handler($this->parser,"tag_open","tag_close");
    xml_set_character_data_handler($this->parser,"cdata");
    xml_set_processing_instruction_handler($this->parser,"tag_pi");
    xml_parse($this->parser,$data);
    if (!xml_parse($this->parser, $data, 1)) {
       $error = sprintf("XML error: %s at line %d",
       xml_error_string(xml_get_error_code($this->parser)),
       xml_get_current_line_number($this->parser));
       echo $error;
    } // if
    xml_parser_free($this->parser);
} // fn     

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-13 07:13 UTC] lobbin@php.net
Can you try this with latest release 4.1.1?
 [2002-02-19 00:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 11:01:29 2024 UTC