2
0
mirror of https://github.com/Unidata/netcdf-c.git synced 2025-03-31 17:50:26 +08:00

fixed string memory leak

This commit is contained in:
Ed Hartnett 2018-02-13 14:17:15 -07:00
parent cb4722a0cf
commit e5cbf259ba
2 changed files with 2 additions and 4 deletions
libsrc4
nc_test4

@ -882,9 +882,7 @@ NC4_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
if (var->type_info->nc_type_class == NC_STRING)
{
assert(*(char **)var->fill_value);
if (!(*(char **)fill_valuep = calloc(1, sizeof(char *))))
return NC_ENOMEM;
/* This will allocate memeory and copy the string. */
if (!(*(char **)fill_valuep = strdup(*(char **)var->fill_value)))
{
free(*(char **)fill_valuep);

@ -514,7 +514,7 @@ main(int argc, char **argv)
if (nc_inq_var_fill(ncid, varid, &no_fill, (char **)fill_value_in)) ERR;
if (no_fill) ERR;
if (strcmp(fill_value_in[0], *string_fillp)) ERR;
if (nc_free_string(1, fill_value_in)) ERR;
if (nc_free_string(1, (char **)fill_value_in)) ERR;
}
if (dim_combo < 2)