aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschnetter <schnetter@6a38eb6e-646e-4a02-a296-d141613ad6c4>2004-03-05 19:57:49 +0000
committerschnetter <schnetter@6a38eb6e-646e-4a02-a296-d141613ad6c4>2004-03-05 19:57:49 +0000
commitc5c55e2e7e07f6e3b354d9f05e766fd6df8f3cd4 (patch)
treee3d22d0366afafbc5aff649aee9f64a2c0184365
parentfb956d2266d98ee45de1199be01815aabcb16db2 (diff)
Fix array indexing bug in Bdry_Boundary_SelectedGVs when there are
multiple bcdata_list objects. Perform some internal consistency checks. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/Boundary/trunk@261 6a38eb6e-646e-4a02-a296-d141613ad6c4
-rw-r--r--src/Boundary.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Boundary.c b/src/Boundary.c
index d9da8a3..5d2f7b3 100644
--- a/src/Boundary.c
+++ b/src/Boundary.c
@@ -895,7 +895,7 @@ CCTK_INT Bdry_Boundary_SelectedGVs(CCTK_POINTER_TO_CONST _GH,
CCTK_INT *table_handles,
CCTK_STRING bc_name)
{
- int retval, i;
+ int retval, i, j;
struct BCVAR *current;
struct BCDATA *current_bcdata;
const cGH *GH = _GH;
@@ -922,6 +922,8 @@ CCTK_INT Bdry_Boundary_SelectedGVs(CCTK_POINTER_TO_CONST _GH,
bc_name, array_size); fflush(stdout);
#endif
+ i = 0; /* i indexes the location in the returned arrays */
+
/* Step through bcdata list */
for (current_bcdata = bcdata_list;
current_bcdata;
@@ -940,7 +942,7 @@ CCTK_INT Bdry_Boundary_SelectedGVs(CCTK_POINTER_TO_CONST _GH,
current = current_bcdata->var_list;
/* Loop through var list */
- for (i=0; /* i indexes the location in the returned arrays */
+ for (j=0; /* j counts the bcs to check internal consistency */
i<array_size && current;
current = current->next, ++i)
{
@@ -968,6 +970,8 @@ CCTK_INT Bdry_Boundary_SelectedGVs(CCTK_POINTER_TO_CONST _GH,
((int *) var_indices)[i] = current->var;
}
}
+ if (j > current_bcdata->num) CCTK_WARN (0, "internal error");
+ if (i != array_size && j != current_bcdata->num) CCTK_WARN (0, "internal error");
}
}