php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18760 PHP crashes on ADDING new nodes using DOM
Submitted: 2002-08-06 13:34 UTC Modified: 2002-08-06 13:48 UTC
From: mangeshd at telera dot com Assigned:
Status: Closed Package: DOM XML related
PHP Version: 4.2.2 OS: Windows 2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mangeshd at telera dot com
New email:
PHP Version: OS:

 

 [2002-08-06 13:34 UTC] mangeshd at telera dot com
Following script will allow you to reproduce the bug. The script doesn't crash when we add 100 nodes but it crashes for a bigger (500) number of nodes. It seesms like it finishes executing all the statements and crashes after the last one.


<?php 

$xmlString = GetBaseAppXML();
if( !$xmlDoc = domxml_open_mem( $xmlString ) ) {
  echo "Error while creating DOM object\n";
  exit;
}

for ( $i=0; $i<500; $i++ ) {
	UpdateAppXML( $xmlDoc, $i, "This" );
}

echo( $xmlDoc->dump_mem( true ));
exit;
function GetBaseAppXML() {
	$strXML = '<?xml version="1.0" ?>';
	$strXML = $strXML.'<XMLPage>';
	$strXML = $strXML.'</XMLPage>';
	
	return $strXML;
}

function UpdateAppXML( &$xmlDoc, $key, $value ) {
	$searchStr = "//SET[@VARNAME = '".$key."']" ;

	$xpathCtx = xpath_new_context( $xmlDoc );
	$arrSetElem = xpath_eval( $xpathCtx, $searchStr );
	$setElem = $arrSetElem->nodeset[0];
	
	if ( is_object( $setElem ) ) {
		$setElem->set_attribute( "VALUE", $value );
	} else {
		$searchStr = "/XMLPage" ;
		$rootElem = $xmlDoc->document_element();
		if ( $rootElem != null ) {
			$newElem = $xmlDoc->create_element( "SET" );
			$newElem->set_attribute( "VARNAME", $key );
			$newElem->set_attribute( "VALUE", $value );
			$newElem = $rootElem->append_child( $newElem );
			unset( $newElem );			
		} else {
			$strMsg = "UpdateAppXML :: Failed to get ROOT element in file: ".$appFilePath ;
			print( "Error processing request<BR>" );
			print( $strMsg );
			unset( $strMsg );
		}			
		unset( $rootElem );
	}
	
	unset( $xpathCtx );
	unset( $arrSetElem );
	unset( $setElem );
}
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-06 13:48 UTC] jtate@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 16:01:29 2024 UTC