Check for consts > 0 before allocating record space for them. Fix to 5683, a malloc(0) bug; thanks to jlnance@inttek.com for catching this one.

git-svn-id: svn://10.0.0.236/trunk@30094 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mccabe%netscape.com 1999-05-04 07:31:40 +00:00
parent 9159fbef9b
commit 08d8615ea7
2 changed files with 18 additions and 2 deletions

View File

@ -37,9 +37,14 @@ static char *strdup(const char *c)
static PRBool
DoInterfaceDirectoryEntry(XPTCursor *cursor,
XPTInterfaceDirectoryEntry *ide, PRUint16 index);
#if 0
/* currently unused */
static PRBool
DoInterfaceDirectoryEntryIndex(XPTCursor *cursor,
XPTInterfaceDirectoryEntry **idep);
#endif
static PRBool
DoConstDescriptor(XPTCursor *cursor, XPTConstDescriptor *cd);
@ -486,9 +491,12 @@ DoInterfaceDescriptor(XPTCursor *outer, XPTInterfaceDescriptor **idp)
goto error;
}
if (mode == XPT_DECODE)
if (mode == XPT_DECODE && id->num_constants) {
id->const_descriptors = XPT_CALLOC(id->num_constants *
sizeof(XPTConstDescriptor));
if (!id->const_descriptors)
goto error;
}
for (i = 0; i < id->num_constants; i++) {
if (!DoConstDescriptor(cursor, &id->const_descriptors[i])) {

View File

@ -37,9 +37,14 @@ static char *strdup(const char *c)
static PRBool
DoInterfaceDirectoryEntry(XPTCursor *cursor,
XPTInterfaceDirectoryEntry *ide, PRUint16 index);
#if 0
/* currently unused */
static PRBool
DoInterfaceDirectoryEntryIndex(XPTCursor *cursor,
XPTInterfaceDirectoryEntry **idep);
#endif
static PRBool
DoConstDescriptor(XPTCursor *cursor, XPTConstDescriptor *cd);
@ -486,9 +491,12 @@ DoInterfaceDescriptor(XPTCursor *outer, XPTInterfaceDescriptor **idp)
goto error;
}
if (mode == XPT_DECODE)
if (mode == XPT_DECODE && id->num_constants) {
id->const_descriptors = XPT_CALLOC(id->num_constants *
sizeof(XPTConstDescriptor));
if (!id->const_descriptors)
goto error;
}
for (i = 0; i < id->num_constants; i++) {
if (!DoConstDescriptor(cursor, &id->const_descriptors[i])) {