From bf8743a61ad867e8a309284dba7b15ecf93cca90 Mon Sep 17 00:00:00 2001 From: jasonw Date: Mon, 2 Aug 2010 18:24:51 +0000 Subject: [PATCH] - all the mallocs in the MResAdjustDRes() function should really be checked independently for success or failure instead of just the CRE malloc git-svn-id: svn://opensvn.adaptivecomputing.com/maui/trunk@140 3f5042e3-fb1d-0410-be18-d6ca2573e517 --- src/moab/MRes.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/moab/MRes.c b/src/moab/MRes.c index cf2b93d..2e3d56a 100644 --- a/src/moab/MRes.c +++ b/src/moab/MRes.c @@ -7133,19 +7133,23 @@ int MResAdjustDRes( /* where possible using memcmp. Insert all container reservation */ /* events at BRes calculation completion */ - if (CRE == NULL) + if (CRE == NULL || ORE == NULL || NRE == NULL || JRE == NULL ) { memset(&ZRes,0,sizeof(ZRes)); - CRE = (mre_t *)malloc(sizeof(mre_t) * (MSched.ResDepth << 1)); - ORE = (mre_t *)malloc(sizeof(mre_t) * (MSched.ResDepth << 1)); - NRE = (mre_t *)malloc(sizeof(mre_t) * (MSched.ResDepth << 1)); - JRE = (mre_t *)malloc(sizeof(mre_t) * (MSched.ResDepth << 1)); + if (CRE == NULL ) + CRE = (mre_t *)malloc(sizeof(mre_t) * (MSched.ResDepth << 1)); + if (ORE == NULL ) + ORE = (mre_t *)malloc(sizeof(mre_t) * (MSched.ResDepth << 1)); + if (NRE == NULL ) + NRE = (mre_t *)malloc(sizeof(mre_t) * (MSched.ResDepth << 1)); + if (JRE == NULL ) + JRE = (mre_t *)malloc(sizeof(mre_t) * (MSched.ResDepth << 1)); DRSize = sizeof(mcres_t); } /* END if (CRE == NULL) */ - if (CRE == NULL) + if (CRE == NULL || ORE == NULL || NRE == NULL || JRE == NULL ) { DBG(4,fCORE) DPrint("ALERT: cannot allocate memory in %s\n", FName);