PHP 4.0 Bug #8425: PHP crashes if I include a page that uses xml parser.
| From: | kirys at kt2k dot com | Date: | Tue, 26 Dec 2000 17:09:27 +0000 |
| Subject: | PHP 4.0 Bug #8425: PHP crashes if I include a page that uses xml parser. | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-42277@lists.php.net to get a copy of this message | ||
From: kirys@kt2k.com
Operating system: Windows NT 4.0
PHP version: 4.0.4
PHP Bug Type: Reproduceable crash
Bug description: PHP crashes if I include a page that uses xml parser.
The same script doesn't crash if used under v4.0.3
no additional modules used
The page MUST be included in a php file
Script Source code:
<?php
echo ".";
$file = "xml/links.xml";
$depth = array();
function startElement($parser, $name, $attrs) {
global $depth;
// for ($i = 0; $i < $depth[$parser]; $i++) {}
switch ($name){
case "LINKPAGE";
print"<TABLE WIDTH=\"98%\" CELLSPACING=2 CELLPADDING=1
BORDER=0>\n";
print"<TR BGCOLOR=\"Blue\"><TD
CLASS=\"ListTitle2\">Title</TD><TD
CLASS=\"ListTitle2\">Vote</TD><TD
CLASS=\"ListTitle2\">Comments</TD></TR>\n";
break;
case "LINK":
print "<TR><TD CLASS=\"ListTitle2\"><A CLASS=\"Menu\"
HREF=\"".$attrs["URL"]."\">".$attrs["TITLE"]."</A></TD>";
print "<TD BGCOLOR=\"Silver\"
ALIGN=\"CENTER\">".$attrs["VOTE"]."</TD><TD
BGCOLOR=\"Silver\">";
break;
case "SECTION":
print "<TR><TD CLASS=\"ListTitle\" COLSPAN=3><CENTER>";
break;
default:
print "<TD>";
}
$depth[$parser]++;
}
function endElement($parser, $name) {
global $depth;
switch ($name){
case "LINKPAGE";
print"<TR><TD Class=\"ListNote\" COLSPAN=3>";
print"<B>Notes</B><BR>";
print"?/10: Means that I didn't decided a vote for that site yet";
print"</TD></TR>";
print"</TABLE>\n";
break;
case "SECTION":
print "</CENTER></TD></TR>";
break;
case "LINK":
echo"</TD></TR>";
break;
default:
echo"</TD></TR>\n";
}
$depth[$parser]--;
}
function characterData($parser, $data) {
print "$data";
}
echo ".";
$xml_parser = xml_parser_create();
echo ".";
xml_set_element_handler($xml_parser, "startElement",
"endElement");
echo ".";
xml_set_character_data_handler($xml_parser, "characterData");
if (!($fp = fopen($file, "r"))) {
die("could not open XML input");
}
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
}
xml_parser_free($xml_parser);
?>
--
Edit Bug report at: http://bugs.php.net/?id=8425&edit=1