diff options
-rw-r--r-- | src/Utils.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/Utils.c b/src/Utils.c index 4870d61..e3b0274 100644 --- a/src/Utils.c +++ b/src/Utils.c @@ -951,8 +951,12 @@ ioRequest *IOUtil_DefaultIORequest (const cGH *GH, int vindex, /* get the variable's dimension and extents */ request->vdim = CCTK_GroupDimFromVarI (vindex); - extent_int = malloc (request->vdim * sizeof (int)); - CCTK_GroupgshVI (GH, request->vdim, extent_int, vindex); + extent_int = NULL; + if (request->vdim > 0) + { + extent_int = malloc (request->vdim * sizeof (int)); + CCTK_GroupgshVI (GH, request->vdim, extent_int, vindex); + } /* allocate the arrays all in one go only initialize those which are mandatory for the Hyperslab API */ @@ -991,7 +995,10 @@ ioRequest *IOUtil_DefaultIORequest (const cGH *GH, int vindex, } /* clean up */ - free (extent_int); + if (extent_int) + { + free (extent_int); + } return (request); } |