- Fix bug #32245 (xml_parser_free() in function assigned to the xml parser

gives a segfault)
This commit is contained in:
Rob Richards 2005-04-28 12:16:32 +00:00
parent 085f2a6980
commit 1ed5c14fe2
2 changed files with 12 additions and 0 deletions

View File

@ -90,6 +90,7 @@ typedef struct {
char **ltags;
int lastwasopen;
int skipwhite;
int isparsing;
XML_Char *baseURI;
} xml_parser;

View File

@ -1076,6 +1076,8 @@ static void php_xml_parser_create_impl(INTERNAL_FUNCTION_PARAMETERS, int ns_supp
parser->target_encoding = encoding;
parser->case_folding = 1;
parser->object = NULL;
parser->isparsing = 0;
XML_SetUserData(parser->parser, parser);
ZEND_REGISTER_RESOURCE(return_value, parser,le_xml_parser);
@ -1334,7 +1336,9 @@ PHP_FUNCTION(xml_parse)
isFinal = 0;
}
parser->isparsing = 1;
ret = XML_Parse(parser->parser, Z_STRVAL_PP(data), Z_STRLEN_PP(data), isFinal);
parser->isparsing = 0;
RETVAL_LONG(ret);
}
@ -1373,7 +1377,9 @@ PHP_FUNCTION(xml_parse_into_struct)
XML_SetElementHandler(parser->parser, _xml_startElementHandler, _xml_endElementHandler);
XML_SetCharacterDataHandler(parser->parser, _xml_characterDataHandler);
parser->isparsing = 1;
ret = XML_Parse(parser->parser, Z_STRVAL_PP(data), Z_STRLEN_PP(data), 1);
parser->isparsing = 0;
RETVAL_LONG(ret);
}
@ -1474,6 +1480,11 @@ PHP_FUNCTION(xml_parser_free)
ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
if (parser->isparsing == 1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Parser cannot be freed while it is parsing.");
RETURN_FALSE;
}
if (zend_list_delete(parser->index) == FAILURE) {
RETURN_FALSE;
}