aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortradke <tradke@20f44201-0f4f-0410-9130-e5fc2714a787>2005-05-12 12:23:54 +0000
committertradke <tradke@20f44201-0f4f-0410-9130-e5fc2714a787>2005-05-12 12:23:54 +0000
commit9454ab75b084f4f59fe362a85dbdb8ea3193d922 (patch)
tree0de3a37e43cba5c9021d41ab7ff2f35b9388b8ab /src
parentb244ba5d56477476abe9015e1ef00766b9f96cd0 (diff)
Also check for zero size when testing pointers to objects allocated by malloc().
git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/RotatingSymmetry180/trunk@21 20f44201-0f4f-0410-9130-e5fc2714a787
Diffstat (limited to 'src')
-rw-r--r--src/interpolate.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/interpolate.c b/src/interpolate.c
index edec57c..7e5f218 100644
--- a/src/interpolate.c
+++ b/src/interpolate.c
@@ -141,12 +141,10 @@ Rot180_SymmetryInterpolate (CCTK_POINTER_TO_CONST const cctkGH_,
new_faces = faces;
new_faces &= ~ (1 << 0);
-
-
/* Copy coordinates */
for (d=0; d<3; ++d) {
new_interp_coords[d] = malloc (N_interp_points * sizeof(CCTK_REAL));
- assert (new_interp_coords[d]);
+ assert (N_interp_points == 0 || new_interp_coords[d]);
memcpy (new_interp_coords[d], interp_coords[d],
N_interp_points * sizeof(CCTK_REAL));
}
@@ -183,7 +181,7 @@ Rot180_SymmetryInterpolate (CCTK_POINTER_TO_CONST const cctkGH_,
/* Find output variable indices */
operand_indices = malloc (N_output_arrays * sizeof *operand_indices);
- assert (operand_indices);
+ assert (N_output_arrays == 0 || operand_indices);
ierr = Util_TableGetIntArray
(param_table_handle, N_output_arrays, operand_indices, "operand_indices");
if (ierr == UTIL_ERROR_TABLE_NO_SUCH_KEY) {
@@ -196,7 +194,7 @@ Rot180_SymmetryInterpolate (CCTK_POINTER_TO_CONST const cctkGH_,
}
operation_codes = malloc (N_output_arrays * sizeof *operation_codes);
- assert (operation_codes);
+ assert (N_output_arrays == 0 || operation_codes);
ierr = Util_TableGetIntArray
(param_table_handle, N_output_arrays, operation_codes, "operation_codes");
if (ierr == UTIL_ERROR_TABLE_NO_SUCH_KEY) {
@@ -210,7 +208,7 @@ Rot180_SymmetryInterpolate (CCTK_POINTER_TO_CONST const cctkGH_,
output_array_indices
= malloc (N_output_arrays * sizeof *output_array_indices);
- assert (output_array_indices);
+ assert (N_output_arrays == 0 || output_array_indices);
for (m=0; m<N_output_arrays; ++m) {
assert (operand_indices[m]>=0 && operand_indices[m]<N_input_arrays);
output_array_indices[m] = input_array_indices[operand_indices[m]];