diff options
author | schnetter <schnetter@b61c5cb5-eaca-4651-9a7a-d64986f99364> | 2005-09-26 00:26:12 +0000 |
---|---|---|
committer | schnetter <schnetter@b61c5cb5-eaca-4651-9a7a-d64986f99364> | 2005-09-26 00:26:12 +0000 |
commit | e7a3e95d815446986410cf338fea46503f1a7100 (patch) | |
tree | 831549520337bd5213f93a228d1b7151e12afb1d /src/Comm.c | |
parent | decfbe2af929ab8ad92ae337f83880dfe95d9875 (diff) |
Insert several checks whether variable indices passed into routines
are legal, and whether malloc returned a null pointer.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGH/trunk@468 b61c5cb5-eaca-4651-9a7a-d64986f99364
Diffstat (limited to 'src/Comm.c')
-rw-r--r-- | src/Comm.c | 25 |
1 files changed, 23 insertions, 2 deletions
@@ -88,7 +88,14 @@ int PUGH_SyncGroup(const cGH *GH, const char *groupname) { CCTK_GroupData(group, &pgroup); - retval = PUGH_SyncGArrayGroup(PUGH_pGH(GH), CCTK_FirstVarIndexI(group)); + if (pgroup.numvars == 0) + { + retval = 0; + } + else + { + retval = PUGH_SyncGArrayGroup(PUGH_pGH(GH), CCTK_FirstVarIndexI(group)); + } } return (retval); @@ -192,6 +199,10 @@ int PUGH_DisableGroupComm(const cGH *GH, const char *groupname) CCTK_GroupData(group, &pgroup); first_var = CCTK_FirstVarIndexI(group); + if (first_var < 0) + { + CCTK_WARN (0, "Illegal group index -- group has no variables"); + } pughGH = PUGH_pGH(GH); GA = (pGA *) pughGH->variables[first_var][0]; @@ -388,6 +399,11 @@ int PUGH_DisableGArrayGroupComm(pGH *pughGH, int first_var, pComm *groupcomm) pGA *GA; /* first variable in group */ + if (first_var < 0) + { + CCTK_WARN (0, "Illegal variable index"); + } + GA = (pGA *) pughGH->variables[first_var][0]; #ifdef DEBUG_PUGH @@ -470,6 +486,11 @@ static int PUGH_EnableGArrayGroupComm(pGH *pughGH, int first_var, int commflag) pGA *GA; /* first variable in group */ + if (first_var < 0) + { + CCTK_WARN (0, "Illegal variable index"); + } + GA = pughGH->variables [first_var][0]; #ifdef DEBUG_PUGH @@ -972,7 +993,7 @@ static int PUGH_SyncSingleProc(pGH *pughGH, pComm *comm) return (0); } - /* since we need to iterators here we need to allocate one */ + /* since we need two iterators here we need to allocate one */ iterator_from = GA->extras->iterator; iterator_to = (int *) malloc (GA->extras->dim * sizeof (int)); |