|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-08-23 16:23 UTC] scottmac@php.net
[2009-08-31 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 18:00:01 2025 UTC |
Description: ------------ When fopen is used without the second parameter, php segfaults in apache 2.2. I had this happen two times, once when I was using bcompiler and once when I was using xml_parser. I thought that the issue was the other modules until I realized that I was missing the second parameter to fopen. I was doing a test on the returned value to check for validity such as if ( $fh ) or if ( is_resource ( $fh ) ) and was unable to see any warnings. Once I removed the test and any interior blocks to the filehandle test from the code, I was able to see a warning. I fixed the issue and have been working solid since. Reproduce code: --------------- $regionf = 'regions.xml' ; $fregions = fopen ( $regionf ) ; if ( $fregions ){ echo "File Opened" ; $xmldoc = fread ( $fregions, filesize ( $regionf ) ) ; $parser = xml_parser_create ( ) ; if ( $parser ){ xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING, "UTF-8"); xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1); xml_parse ( $parser, $doc ) ; xml_parse_into_struct($parser, trim($xmldoc), $xml_values); print_r ( $xml_values ) ; xml_parser_free ( $parser ) ; } fclose ( $fregions ) ; } Expected result: ---------------- apache segfault - browser displays previous content ( cache )