From 08bf172e28b68044829782c1916bc486f2403386 Mon Sep 17 00:00:00 2001 From: "mccabe%netscape.com" Date: Tue, 18 May 1999 02:10:05 +0000 Subject: [PATCH] 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 for finding this, and to Mike Shaver 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 --- mozilla/xpcom/libxpt/src/xpt_struct.c | 16 +++++++++------- mozilla/xpcom/typelib/xpt/src/xpt_struct.c | 16 +++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/mozilla/xpcom/libxpt/src/xpt_struct.c b/mozilla/xpcom/libxpt/src/xpt_struct.c index 1856c666b89..51ac1e26979 100644 --- a/mozilla/xpcom/libxpt/src/xpt_struct.c +++ b/mozilla/xpcom/libxpt/src/xpt_struct.c @@ -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; diff --git a/mozilla/xpcom/typelib/xpt/src/xpt_struct.c b/mozilla/xpcom/typelib/xpt/src/xpt_struct.c index 1856c666b89..51ac1e26979 100644 --- a/mozilla/xpcom/typelib/xpt/src/xpt_struct.c +++ b/mozilla/xpcom/typelib/xpt/src/xpt_struct.c @@ -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;