fix a nasty problem with reading over the end fix a reported memory leak

* xmlreader.c: fix a nasty problem with reading over the end
* xmlsave.c: fix a reported memory leak apparently
Daniel
This commit is contained in:
Daniel Veillard 2004-04-29 17:14:25 +00:00
parent 9ea6231ece
commit e2161a699b
3 changed files with 13 additions and 1 deletions

View File

@ -1,3 +1,8 @@
Thu Apr 29 20:15:20 CEST 2004 Daniel Veillard <daniel@veillard.com>
* xmlreader.c: fix a nasty problem with reading over the end
* xmlsave.c: fix a reported memory leak apparently
Thu Apr 29 17:05:00 CEST 2004 Daniel Veillard <daniel@veillard.com>
* win32/Makefile.msvc: patch from Mark Vakoc for regression tests

View File

@ -1179,6 +1179,8 @@ xmlTextReaderRead(xmlTextReaderPtr reader) {
fprintf(stderr, "\nREAD ");
DUMP_READER
#endif
if (reader->mode == XML_TEXTREADER_DONE)
return(0);
reader->curnode = NULL;
if (reader->mode == XML_TEXTREADER_MODE_INITIAL) {
reader->mode = XML_TEXTREADER_MODE_INTERACTIVE;
@ -1215,12 +1217,15 @@ xmlTextReaderRead(xmlTextReaderPtr reader) {
oldnode = reader->node;
get_next_node:
if (reader->node == NULL)
return(-1);
/*
* If we are not backtracking on ancestors or examined nodes,
* that the parser didn't finished or that we arent at the end
* of stream, continue processing.
*/
while ((reader->node->next == NULL) &&
while ((reader->node != NULL) && (reader->node->next == NULL) &&
(reader->ctxt->nodeNr == olddepth) &&
((oldstate == XML_TEXTREADER_BACKTRACK) ||
(reader->node->children == NULL) ||

View File

@ -179,6 +179,8 @@ xmlFreeSaveCtxt(xmlSaveCtxtPtr ctxt)
if (ctxt == NULL) return;
if (ctxt->encoding != NULL)
xmlFree((char *) ctxt->encoding);
if (ctxt->buf != NULL)
xmlOutputBufferClose(ctxt->buf);
xmlFree(ctxt);
}