mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-26 23:13:13 +02:00
XML_Parser::storeAtts: don't leak in case of realloc failure
This commit is contained in:
committed by
svenhoefer
parent
0cd6cfa68c
commit
6944d53cef
@@ -132,7 +132,8 @@ XML_Parser::XML_Parser(const XML_Char *encodingName)
|
||||
tagStack=0;
|
||||
freeTagList=0;
|
||||
attsSize=INIT_ATTS_SIZE;
|
||||
atts=new ATTRIBUTE[attsSize];
|
||||
/* must not realloc stuff allocated with new[] */
|
||||
atts=(ATTRIBUTE *)malloc(attsSize * sizeof(ATTRIBUTE));
|
||||
dataBuf=new XML_Char[INIT_DATA_BUF_SIZE];
|
||||
groupSize=0;
|
||||
groupConnector=0;
|
||||
@@ -152,7 +153,7 @@ XML_Parser::XML_Parser(const XML_Char *encodingName)
|
||||
poolDestroy(&tempPool);
|
||||
poolDestroy(&temp2Pool);
|
||||
|
||||
if (atts) delete[] atts;
|
||||
if (atts) free(atts);
|
||||
if (dataBuf) delete[] dataBuf;
|
||||
|
||||
return;
|
||||
@@ -204,7 +205,7 @@ XML_Parser::~XML_Parser()
|
||||
poolDestroy(&temp2Pool);
|
||||
dtdDestroy(&dtd);
|
||||
|
||||
delete[] atts;
|
||||
free(atts);
|
||||
free(groupConnector);
|
||||
free(buffer);
|
||||
delete[] dataBuf;
|
||||
@@ -1099,9 +1100,11 @@ enum XML_Error XML_Parser::storeAtts(const ENCODING *enc, const XML_Char *tagNam
|
||||
|
||||
attsSize=n+nDefaultAtts+INIT_ATTS_SIZE;
|
||||
|
||||
atts=(ATTRIBUTE *) realloc((void *) atts, attsSize*sizeof(ATTRIBUTE));
|
||||
ATTRIBUTE *newatts = (ATTRIBUTE *) realloc((void *) atts, attsSize*sizeof(ATTRIBUTE));
|
||||
|
||||
if (!atts) return XML_ERROR_NO_MEMORY;
|
||||
if (!newatts) return XML_ERROR_NO_MEMORY;
|
||||
|
||||
atts = newatts;
|
||||
|
||||
if (n>oldAttsSize) XmlGetAttributes(enc, s, n, atts);
|
||||
};
|
||||
|
Reference in New Issue
Block a user