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:
parent
cb4722a0cf
commit
e5cbf259ba
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user