DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7164>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7164

DOMParser with a DTD leak!





------- Additional Comments From [EMAIL PROTECTED]  2002-03-25 20:09 -------
Jean,

    Though your patch seem eliminate the momory leak to this particular bug, 
but overall, I am afraid it is not the way it is supposed to be.

    The algo for DOMParser::endAttrList is like this, for any incoming element 
(ElemDecl in the code) with default attribute, create a temporary element (elem 
in the code), with default attribute list set, from the element pool (owned by 
the documentType), then loop through the default attribute list of the incoming 
element, and insert each attribute to the tempoary element and once finished, 
insert this temporary element (the elem) into the element pool.

    The leak occurs if, the temporary element's default attribute list has a  
same attribute name which exists in the incoming element's default attribute 
list, it will be overwritten by the new one from the incoming elements', and 
left unattached to any thing, becoming dangling and therefore, not released 
properly.

    To solve this, my patch will capture this kind attribute and delete it if 
necessary.

    so instead of simply do
        
       elem->setAttributeNode(insertAttr);

    we check and delete:

       AttrImpl * previousAttr = elem->setAttributeNode(insertAttr);
       if ( previousAttr != 0 && previousAttr->nodeRefCount ==0)
            NodeImpl::deleteIf(previousAttr);

    The reason why your patch does not have a leak, is, your element will be 
put into entity pool, not element pool, so any temp element created from 
element poool natually does not have an initial default attribute list, and 
there fore no leak occurs, and you happen to delete the element from entity 
pool if it is already there. 

     I'd suggest you run samples from the latest code base against your test 
case and check the result, instead of running **YOUR** code against your test 
case. Please let us know if the leakage persists. thanks.

PeiYong

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to