From 5212941c550ef9377ed59f182f5846345da74b9b Mon Sep 17 00:00:00 2001 From: DKRZ-Xingran <wang@dkrz.de> Date: Mon, 28 Feb 2022 16:13:59 +0100 Subject: [PATCH] fix: do not malloc zero byte for zaxis --- src/zaxis.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zaxis.c b/src/zaxis.c index 3fa358075..a1fbc3862 100644 --- a/src/zaxis.c +++ b/src/zaxis.c @@ -760,7 +760,7 @@ void zaxisDefLevels(int zaxisID, const double *levels) if ( levels ) { - if ( zaxisptr->vals == NULL ) + if ( zaxisptr->vals == NULL && size != (size_t) 0 ) zaxisptr->vals = (double*) Malloc(size*sizeof(double)); double *vals = zaxisptr->vals; @@ -792,7 +792,7 @@ void zaxisDefLevel(int zaxisID, int levelID, double level) zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID); int size = zaxisptr->size; - if ( zaxisptr->vals == NULL ) + if ( zaxisptr->vals == NULL && size != 0 ) zaxisptr->vals = (double*) Malloc((size_t)size*sizeof(double)); if ( levelID >= 0 && levelID < size ) -- GitLab