ID: 33059 Updated by: [EMAIL PROTECTED] Reported By: dikrib at hotmail dot com -Status: Open +Status: Verified Bug Type: DOM XML related Operating System: Windows XP PHP Version: 5.0.4 New Comment:
valgrind also shows some errors there: ==6404== Invalid read of size 4 ==6404== at 0x1B9ED17B: xmlUnlinkNode (in /usr/lib/libxml2.so.2.6.17) ==6404== by 0x1BA07635: (within /usr/lib/libxml2.so.2.6.17) ==6404== by 0x1B9F68CF: xmlHashFree (in /usr/lib/libxml2.so.2.6.17) ==6404== by 0x1BA05926: xmlFreeAttributeTable (in /usr/lib/libxml2.so.2.6.17) ==6404== Address 0x1BD0A61C is 4 bytes inside a block of size 64 free'd ==6404== at 0x1B9060B1: free (in /usr/lib/valgrind/vgpreload_memcheck.so) ==6404== by 0x1B9F1C1A: xmlFreeProp (in /usr/lib/libxml2.so.2.6.17) ==6404== by 0x807B430: zif_dom_element_remove_attribute (element.c:301) ==6404== by 0x8194284: zend_do_fcall_common_helper (zend_execute.c:2747) Previous Comments: ------------------------------------------------------------------------ [2005-05-18 21:08:21] dikrib at hotmail dot com Description: ------------ If I try to remove an attribute from an xml document using the dom, where the xml document is validated against a doctype, and the dtd specifies a default value for the attribute, PHP crashes if the attribute is not defined. My guess is that the default value is receaved from the dtd, and php therefore beleaves that the attribute exists and passes the error checking, that should have caused the removeAttribute property to return false. Tested on PHP 5.0.4 and php5.0-win32-200505181630 Reproduce code: --------------- <?php $doc = new DOMDocument(); $doc->validateOnParse = true; $doc->loadXML('<?xml version="1.0" encoding="iso-8859-1"?'.'> <!DOCTYPE node [ <!ELEMENT node EMPTY> <!ATTLIST node attr CDATA ""> ]> <node></node>'); $node = $doc->documentElement; $node->removeAttribute('attr'); Expected result: ---------------- the removeAttribute property should return false, because the attribute is not defined. Actual result: -------------- The webserver crashes. I get a message from Windows saying: "Apache.exe has encountered a problem and needs to close."... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33059&edit=1