[ expat-Bugs-553318 ] XML_ParserReset does not reset everythi

noreply@sourceforge.net noreply@sourceforge.net
Sat May 18 11:17:03 2002


Bugs item #553318, was opened at 2002-05-07 11:37
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=110127&aid=553318&group_id=10127

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Karl Waclawek (kwaclaw)
Assigned to: Karl Waclawek (kwaclaw)
Summary: XML_ParserReset  does not reset everythi

Initial Comment:
I have identified three problems with XML_ParserReset
in xmlparse.ca rev. 1.31:

1) tempPool and temp2Pool are not cleared, which means
   that they may grow much larger than needed
   (the poolClear function does not deallocate memory!)

2) the dtd structure is not reset

3) it should not be legal to call XML_ParserReset
   on a child parser, since sometimes the child
   parser shares the dtd structure with the parent
   parser, and because a child parser created
   for parsing an external entity cannot be used
   for the same purpose anymore - the initialization
   would need to be different

I propose to split XML_ParserReset into two functions,
an internal one, called parserInit, and an exported
one with the original name. This one would then use
parserInit like this:

int XML_ParserReset(XML_Parser parser, const XML_Char 
*encodingName)
{
  if (parentParser) return 0; 
#ifdef XML_DTD
  if (dtd.scaffold) dtdDestroy(&dtd, parser);
#endif
  poolClear(&tempPool);
  poolClear(&temp2Pool);
  return parserInit(parser, encodingName);
}

whereas parserInit would be called by 
XML_ParserCreate_MM instead of XML_ParserReset,
since not everything that applies to the exported
version applies to the internal one.

This examples necessitates that parentParser
is always set for a child parser, which is currently
not the case, but patch # 551599 includes it as a
"byproduct" of fixing bug # 549014.

Also, parserInit (and consequently XML_ParserReset)
may potentially fail (since parserInit calls
dtdInit internally) and therefore the return type
should be changed from void to int.

Changes according to this have been included
in patch # 551599 (2nd improved version).


Karl

----------------------------------------------------------------------

>Comment By: Karl Waclawek (kwaclaw)
Date: 2002-05-18 14:16

Message:
Logged In: YES 
user_id=290026

Proposed fix is part of patch # 551599 which has been
checked in. Let's wait until more testing has been done.

Karl

----------------------------------------------------------------------

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2002-05-07 11:53

Message:
Logged In: YES 
user_id=3066

Sounds good to me.  Assigning to you since you've already
written the patch.  ;-)

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=110127&aid=553318&group_id=10127