From 335f25e947e5eda1846103fb7d96e4dc285afaf0 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Fri, 8 Jun 2018 11:38:11 -0600 Subject: [PATCH] Corrected a couple of potential memory related issues and an uninitialized variable issue. --- libdispatch/dfile.c | 20 +++++++++++++------- ncgen/genbin.c | 4 ++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/libdispatch/dfile.c b/libdispatch/dfile.c index 62f9fd196..576912dcc 100644 --- a/libdispatch/dfile.c +++ b/libdispatch/dfile.c @@ -2192,13 +2192,19 @@ NC_open(const char *path0, int cmode, int basepe, size_t *chunksizehintp, #ifdef USE_CDF5 cdf5built = 1; #endif - if(!hdf5built && model == NC_FORMATX_NC4) - return NC_ENOTBUILT; - if(!hdf4built && model == NC_FORMATX_NC4 && version == 4) - return NC_ENOTBUILT; - if(!cdf5built && model == NC_FORMATX_NC3 && version == 5) - return NC_ENOTBUILT; - } + if(!hdf5built && model == NC_FORMATX_NC4) { + free(path); + return NC_ENOTBUILT; + } + if(!hdf4built && model == NC_FORMATX_NC4 && version == 4) { + free(path); + return NC_ENOTBUILT; + } + if(!cdf5built && model == NC_FORMATX_NC3 && version == 5) { + free(path); + return NC_ENOTBUILT; + } + } /* Force flag consistentcy */ if(model == NC_FORMATX_NC4 || model == NC_FORMATX_NC_HDF4 || model == NC_FORMATX_DAP4) diff --git a/ncgen/genbin.c b/ncgen/genbin.c index 29df7793d..56b35bea4 100644 --- a/ncgen/genbin.c +++ b/ncgen/genbin.c @@ -198,7 +198,7 @@ genbin_defineglobalspecials(void) static void genbin_definespecialattributes(Symbol* var) { - int stat; + int stat = NC_NOERR; Specialdata* special = &var->var.special; if(special->flags & _STORAGE_FLAG) { int storage = special->_Storage; @@ -250,7 +250,7 @@ genbin_definespecialattributes(Symbol* var) else level = special->_FilterParams[0]; if(level > 9) - derror("Illegal deflate level"); + derror("Illegal deflate level"); else { stat = nc_def_var_deflate(var->container->ncid, var->ncid,