From 9454ab75b084f4f59fe362a85dbdb8ea3193d922 Mon Sep 17 00:00:00 2001 From: tradke Date: Thu, 12 May 2005 12:23:54 +0000 Subject: 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 --- src/interpolate.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src') 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=0 && operand_indices[m]