GNOME Bugzilla – Bug 366161
xmlCtxtReset() crashes when ctxt->spaceTab happens to be NULL
Last modified: 2007-06-12 08:18:30 UTC
Steps to reproduce: I'd like to call xmlCtxtReset() - or rather xmlClearParserCtxt() - after running xmlCtxtRead*() to free memory resources and to close open input streams. However, in some cases, this crashes on line 12837 in file parser.c where it says: ctxt->spaceTab[0] = -1; Apparently, this line assumes that spaceTab is never NULL, which does not appear to be a correct assumption, especially (but not only) in the case of errors. I'd like to see this code section enclosed by a NULL test just like every other similar part of this function to make it more resilient. Stack trace: Other information:
FWIW, both htmlCtxtReset and xmlFreeParserCtxt do the NULL check on ctxt->spaceTab. xmlCtxtReset doesn't. It seems that the only place where ctx->spaceTab could end up as NULL is in spacePush, if xmlRealloc fails. spacePush then would just return 0 and that doesn't seem to be checked anywhere.
Okay, trivial, fixed in SVN, Daniel