From db8d23b9862a3f57a0f9f95df139d6eba8810273 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Thu, 31 May 2018 15:09:11 -0600 Subject: [PATCH] Removed a potential double-free identified by static analysis. --- libsrc/nc3internal.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libsrc/nc3internal.c b/libsrc/nc3internal.c index 7cd665e34..fb99798d9 100644 --- a/libsrc/nc3internal.c +++ b/libsrc/nc3internal.c @@ -584,7 +584,7 @@ fill_added(NC3_INFO *gnu, NC3_INFO *old) { const NC_var *const gnu_varp = *(gnu_varpp + varid); - if (gnu_varp->no_fill) continue; + if (gnu_varp->no_fill) continue; if(IS_RECVAR(gnu_varp)) { @@ -1203,9 +1203,12 @@ NC3_open(const char * path, int ioflags, * !_CRAYMPP, only pe 0 is valid */ if(basepe != 0) { - if(nc3) free(nc3); - status = NC_EINVAL; - goto unwind_alloc; + if(nc3) { + free(nc3); + nc3 = NULL; + } + status = NC_EINVAL; + goto unwind_alloc; } #endif @@ -1743,7 +1746,7 @@ NC3_inq_format_extended(int ncid, int *formatp, int *modep) * Determine name and size of netCDF type. This netCDF-4 function * proved so popular that a netCDF-classic version is provided. You're * welcome. - * + * * \param ncid The ID of an open file. * \param typeid The ID of a netCDF type. * \param name Pointer that will get the name of the type. Maximum