mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-02-17 16:50:18 +08:00
Merge pull request #649 from NetCDF-World-Domination-Council/ejh_new_mem_error
BUGFIX: Fixes 3 memory leaks, in tst_filterparser.c, nc4internal.c, and dfilter.c
This commit is contained in:
commit
f6828b4b5e
@ -166,8 +166,10 @@ NC_parsefilterspec(const char* spec, unsigned int* idp, size_t* nparamsp, unsign
|
|||||||
/* Now return results */
|
/* Now return results */
|
||||||
if(idp) *idp = id;
|
if(idp) *idp = id;
|
||||||
if(nparamsp) *nparamsp = nparams;
|
if(nparamsp) *nparamsp = nparams;
|
||||||
if(paramsp) *paramsp = ulist;
|
if(paramsp) {
|
||||||
ulist = NULL; /* avoid duplicate free */
|
*paramsp = ulist;
|
||||||
|
ulist = NULL; /* avoid duplicate free */
|
||||||
|
}
|
||||||
if(sdata) free(sdata);
|
if(sdata) free(sdata);
|
||||||
if(ulist) free(ulist);
|
if(ulist) free(ulist);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1071,6 +1071,10 @@ nc4_var_del(NC_VAR_INFO_T *var)
|
|||||||
if (var->dimscale_attached)
|
if (var->dimscale_attached)
|
||||||
free(var->dimscale_attached);
|
free(var->dimscale_attached);
|
||||||
|
|
||||||
|
/* Release parameter information. */
|
||||||
|
if (var->params)
|
||||||
|
free(var->params);
|
||||||
|
|
||||||
/* Delete the var. */
|
/* Delete the var. */
|
||||||
free(var);
|
free(var);
|
||||||
|
|
||||||
|
@ -59,7 +59,9 @@ static int nerrs = 0;
|
|||||||
static int parsefilterspec(const char* spec, unsigned int* idp, size_t* nparamsp, unsigned int** paramsp);
|
static int parsefilterspec(const char* spec, unsigned int* idp, size_t* nparamsp, unsigned int** paramsp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WORD_BIGENDIAN
|
||||||
static void byteswap8(unsigned char* mem);
|
static void byteswap8(unsigned char* mem);
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
report(const char* which)
|
report(const char* which)
|
||||||
@ -72,7 +74,7 @@ report(const char* which)
|
|||||||
static void
|
static void
|
||||||
mismatch(size_t i, unsigned int baseline, unsigned int params)
|
mismatch(size_t i, unsigned int baseline, unsigned int params)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"mismatch: [%d] baseline=%ud spec=%ud\n",i,baseline,params);
|
fprintf(stderr,"mismatch: [%d] baseline=%ud spec=%ud\n",(int)i,baseline,params);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
nerrs++;
|
nerrs++;
|
||||||
}
|
}
|
||||||
@ -86,6 +88,8 @@ main(int argc, char **argv)
|
|||||||
size_t i,nparams = 0;
|
size_t i,nparams = 0;
|
||||||
unsigned int* params = NULL;
|
unsigned int* params = NULL;
|
||||||
|
|
||||||
|
printf("\nTesting filter parser.\n");
|
||||||
|
|
||||||
#ifdef USE_INTERNAL
|
#ifdef USE_INTERNAL
|
||||||
stat = parsefilterspec(spec,&id,&nparams,¶ms);
|
stat = parsefilterspec(spec,&id,&nparams,¶ms);
|
||||||
#else
|
#else
|
||||||
@ -125,9 +129,16 @@ main(int argc, char **argv)
|
|||||||
if(ul.ull != 18446744073709551615ULL)
|
if(ul.ull != 18446744073709551615ULL)
|
||||||
report("ul.ull");
|
report("ul.ull");
|
||||||
|
|
||||||
|
if (params)
|
||||||
|
free(params);
|
||||||
|
|
||||||
|
if (!nerrs)
|
||||||
|
printf("SUCCESS!!\n");
|
||||||
|
|
||||||
return (nerrs > 0 ? 1 : 0);
|
return (nerrs > 0 ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WORD_BIGENDIAN
|
||||||
/* Byte swap an 8-byte integer in place */
|
/* Byte swap an 8-byte integer in place */
|
||||||
static void
|
static void
|
||||||
byteswap8(unsigned char* mem)
|
byteswap8(unsigned char* mem)
|
||||||
@ -146,6 +157,7 @@ byteswap8(unsigned char* mem)
|
|||||||
mem[3] = mem[4];
|
mem[3] = mem[4];
|
||||||
mem[4] = c;
|
mem[4] = c;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_INTERNAL
|
#ifdef USE_INTERNAL
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user