Only alloc space for interface records if we actually have interfaces; fixes a calloc(1,0) bug that was breaking the AIX build. (Thanks to Jim Dunn <jdunn@netscape.com> for finding this, and to Mike Shaver <shaver@netscape.com> for contributing the patch.

The xpcom tree remains closed, but this patch gets in for m6 by special dispensation.

A=leaf,dp


git-svn-id: svn://10.0.0.236/trunk@32011 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mccabe%netscape.com
1999-05-18 02:10:05 +00:00
parent 7e5b8dacb8
commit 08bf172e28
2 changed files with 18 additions and 14 deletions

View File

@@ -117,11 +117,13 @@ XPT_NewHeader(PRUint16 num_interfaces)
header->major_version = XPT_MAJOR_VERSION;
header->minor_version = XPT_MINOR_VERSION;
header->num_interfaces = num_interfaces;
header->interface_directory = XPT_CALLOC(num_interfaces *
sizeof(XPTInterfaceDirectoryEntry));
if (!header->interface_directory) {
XPT_DELETE(header);
return NULL;
if (num_interfaces) {
header->interface_directory = XPT_CALLOC(num_interfaces *
sizeof(XPTInterfaceDirectoryEntry));
if (!header->interface_directory) {
XPT_DELETE(header);
return NULL;
}
}
header->data_pool = 0; /* XXX do we even need this struct any more? */
@@ -172,7 +174,7 @@ XPT_DoHeader(XPTCursor *cursor, XPTHeader **headerp)
if (mode == XPT_DECODE)
XPT_DataOffset(cursor->state, &header->data_pool);
if (mode == XPT_DECODE) {
if (mode == XPT_DECODE && header->num_interfaces) {
header->interface_directory =
XPT_CALLOC(header->num_interfaces *
sizeof(XPTInterfaceDirectoryEntry));
@@ -591,7 +593,7 @@ XPT_FillMethodDescriptor(XPTMethodDescriptor *meth, PRUint8 flags, char *name,
if (!name)
return PR_FALSE;
meth->num_args = num_args;
if (meth->num_args) {
if (num_args) {
meth->params = XPT_CALLOC(num_args * sizeof(XPTParamDescriptor));
if (!meth->params)
goto free_name;

View File

@@ -117,11 +117,13 @@ XPT_NewHeader(PRUint16 num_interfaces)
header->major_version = XPT_MAJOR_VERSION;
header->minor_version = XPT_MINOR_VERSION;
header->num_interfaces = num_interfaces;
header->interface_directory = XPT_CALLOC(num_interfaces *
sizeof(XPTInterfaceDirectoryEntry));
if (!header->interface_directory) {
XPT_DELETE(header);
return NULL;
if (num_interfaces) {
header->interface_directory = XPT_CALLOC(num_interfaces *
sizeof(XPTInterfaceDirectoryEntry));
if (!header->interface_directory) {
XPT_DELETE(header);
return NULL;
}
}
header->data_pool = 0; /* XXX do we even need this struct any more? */
@@ -172,7 +174,7 @@ XPT_DoHeader(XPTCursor *cursor, XPTHeader **headerp)
if (mode == XPT_DECODE)
XPT_DataOffset(cursor->state, &header->data_pool);
if (mode == XPT_DECODE) {
if (mode == XPT_DECODE && header->num_interfaces) {
header->interface_directory =
XPT_CALLOC(header->num_interfaces *
sizeof(XPTInterfaceDirectoryEntry));
@@ -591,7 +593,7 @@ XPT_FillMethodDescriptor(XPTMethodDescriptor *meth, PRUint8 flags, char *name,
if (!name)
return PR_FALSE;
meth->num_args = num_args;
if (meth->num_args) {
if (num_args) {
meth->params = XPT_CALLOC(num_args * sizeof(XPTParamDescriptor));
if (!meth->params)
goto free_name;