[Expat-checkins] expat/lib xmlparse.c,1.34,1.35
fdrake@users.sourceforge.net
fdrake@users.sourceforge.net
Fri May 17 08:22:05 2002
Update of /cvsroot/expat/expat/lib
In directory usw-pr-cvs1:/tmp/cvs-serv10784/lib
Modified Files:
xmlparse.c
Log Message:
Hopefully the last needed checks for MALLOC() failure in xmlparse.c, this
avoids memory faults when the initial allocations fail, returning NULL to
the caller instead.
This closes SF bug #496505.
Index: xmlparse.c
===================================================================
RCS file: /cvsroot/expat/expat/lib/xmlparse.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** xmlparse.c 17 May 2002 15:09:34 -0000 1.34
--- xmlparse.c 17 May 2002 15:21:53 -0000 1.35
***************
*** 573,577 ****
const XML_Memory_Handling_Suite *memsuite,
const XML_Char *nameSep) {
-
XML_Parser parser;
static const XML_Char implicitContext[] = {
--- 573,576 ----
***************
*** 586,601 ****
XML_Memory_Handling_Suite *mtemp;
parser = memsuite->malloc_fcn(sizeof(Parser));
! mtemp = &(((Parser *) parser)->m_mem);
! mtemp->malloc_fcn = memsuite->malloc_fcn;
! mtemp->realloc_fcn = memsuite->realloc_fcn;
! mtemp->free_fcn = memsuite->free_fcn;
}
else {
XML_Memory_Handling_Suite *mtemp;
parser = malloc(sizeof(Parser));
! mtemp = &(((Parser *) parser)->m_mem);
! mtemp->malloc_fcn = malloc;
! mtemp->realloc_fcn = realloc;
! mtemp->free_fcn = free;
}
--- 585,604 ----
XML_Memory_Handling_Suite *mtemp;
parser = memsuite->malloc_fcn(sizeof(Parser));
! if (parser != NULL) {
! mtemp = &(((Parser *) parser)->m_mem);
! mtemp->malloc_fcn = memsuite->malloc_fcn;
! mtemp->realloc_fcn = memsuite->realloc_fcn;
! mtemp->free_fcn = memsuite->free_fcn;
! }
}
else {
XML_Memory_Handling_Suite *mtemp;
parser = malloc(sizeof(Parser));
! if (parser != NULL) {
! mtemp = &(((Parser *) parser)->m_mem);
! mtemp->malloc_fcn = malloc;
! mtemp->realloc_fcn = realloc;
! mtemp->free_fcn = free;
! }
}
***************
*** 608,612 ****
--- 611,624 ----
attsSize = INIT_ATTS_SIZE;
atts = MALLOC(attsSize * sizeof(ATTRIBUTE));
+ if (atts == NULL) {
+ FREE(parser);
+ return NULL;
+ }
dataBuf = MALLOC(INIT_DATA_BUF_SIZE * sizeof(XML_Char));
+ if (dataBuf == NULL) {
+ FREE(atts);
+ FREE(parser);
+ return NULL;
+ }
dataBufEnd = dataBuf + INIT_DATA_BUF_SIZE;
freeBindingList = 0;