Permalink
Browse files

Fix some potential problems on reallocation failures(parser.c)

This problem is the same as d7958b2.
The operation "ctxt->nameMax * = 2;" should be placed after the function
call of xmlRealloc().
  • Loading branch information...
1 parent bbcf127 commit 5825ebb26a336d57cf31d0f9534829b74a2f852e @xiaxf xiaxf committed with veillard Nov 10, 2011
Showing with 2 additions and 3 deletions.
  1. +2 −3 parser.c
View
@@ -1820,15 +1820,14 @@ namePush(xmlParserCtxtPtr ctxt, const xmlChar * value)
if (ctxt->nameNr >= ctxt->nameMax) {
const xmlChar * *tmp;
- ctxt->nameMax *= 2;
tmp = (const xmlChar * *) xmlRealloc((xmlChar * *)ctxt->nameTab,
- ctxt->nameMax *
+ ctxt->nameMax * 2 *
sizeof(ctxt->nameTab[0]));
if (tmp == NULL) {
- ctxt->nameMax /= 2;
goto mem_error;
}
ctxt->nameTab = tmp;
+ ctxt->nameMax *= 2;
}
ctxt->nameTab[ctxt->nameNr] = value;
ctxt->name = value;

0 comments on commit 5825ebb

Please sign in to comment.