Skip to content
Snippets Groups Projects
Commit 5212941c authored by Xingran Wang's avatar Xingran Wang
Browse files

fix: do not malloc zero byte for zaxis

parent fe516429
No related branches found
No related tags found
No related merge requests found
Pipeline #15705 failed
...@@ -760,7 +760,7 @@ void zaxisDefLevels(int zaxisID, const double *levels) ...@@ -760,7 +760,7 @@ void zaxisDefLevels(int zaxisID, const double *levels)
if ( levels ) if ( levels )
{ {
if ( zaxisptr->vals == NULL ) if ( zaxisptr->vals == NULL && size != (size_t) 0 )
zaxisptr->vals = (double*) Malloc(size*sizeof(double)); zaxisptr->vals = (double*) Malloc(size*sizeof(double));
double *vals = zaxisptr->vals; double *vals = zaxisptr->vals;
...@@ -792,7 +792,7 @@ void zaxisDefLevel(int zaxisID, int levelID, double level) ...@@ -792,7 +792,7 @@ void zaxisDefLevel(int zaxisID, int levelID, double level)
zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID); zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
int size = zaxisptr->size; int size = zaxisptr->size;
if ( zaxisptr->vals == NULL ) if ( zaxisptr->vals == NULL && size != 0 )
zaxisptr->vals = (double*) Malloc((size_t)size*sizeof(double)); zaxisptr->vals = (double*) Malloc((size_t)size*sizeof(double));
if ( levelID >= 0 && levelID < size ) if ( levelID >= 0 && levelID < size )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment