[ expat-Bugs-496505 ] checking for malloc failures

noreply@sourceforge.net noreply@sourceforge.net
Fri May 17 08:26:04 2002


Bugs item #496505, was opened at 2001-12-24 11:37
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=110127&aid=496505&group_id=10127

Category: None
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Eric C. Newton (ericnewton)
>Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: checking for malloc failures

Initial Comment:
expat 1.95.2 (under RedHat linux 2.4)

The following code (xmlparse.c:578) will crash, should
the malloc() call fail:

    XML_Memory_Handling_Suite *mtemp;
    parser = malloc(sizeof(Parser));
    mtemp = &(((Parser *) parser)->m_mem);
    mtemp->malloc_fcn = malloc;


Likewise (xmlparse.c:1139) XML_GetBuffer() returns NULL
when malloc() fails, and the result is not checked:

    memcpy(XML_GetBuffer(parser, len), s, len);

Other than that, expat works quite well.  Very nice
library.

-Eric


----------------------------------------------------------------------

>Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2002-05-17 11:25

Message:
Logged In: YES 
user_id=3066

The unchecked use of the XML_GetBuffer() return value in
XML_Parse() was fixed in CVS a while ago, but possibly after
this bug report was filed.  I've added the remaining
MALLOC() and REALLOC() checks in lib/xmlparse.c revisions
1.33 though 1.35.  These will be part of the 1.95.3 release.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=110127&aid=496505&group_id=10127