mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-30 16:10:44 +08:00
Addressing a handful of coverity issues.
This commit is contained in:
parent
99de533569
commit
7a68cb8e83
@ -135,8 +135,10 @@ nc4_get_att(int ncid, NC *nc, int varid, const char *name,
|
||||
size_t base_typelen = type_size;
|
||||
hvl_t *vldest = data;
|
||||
NC_TYPE_INFO_T *type;
|
||||
if ((retval = nc4_find_type(h5, att->xtype, &type)))
|
||||
return retval;
|
||||
if ((retval = nc4_find_type(h5, att->xtype, &type))) {
|
||||
if(bufr) free(bufr);
|
||||
return retval;
|
||||
}
|
||||
for (i = 0; i < att->len; i++)
|
||||
{
|
||||
vldest[i].len = att->vldata[i].len;
|
||||
|
@ -189,8 +189,11 @@ nc_check_for_hdf(const char *path, int use_parallel, MPI_Comm comm, MPI_Info inf
|
||||
{
|
||||
FILE *fp;
|
||||
if (!(fp = fopen(path, "r")) ||
|
||||
fread(blob, MAGIC_NUMBER_LEN, 1, fp) != 1)
|
||||
return errno;
|
||||
fread(blob, MAGIC_NUMBER_LEN, 1, fp) != 1) {
|
||||
|
||||
if(fp) fclose(fp);
|
||||
return errno;
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
@ -1022,7 +1025,7 @@ read_type(NC_GRP_INFO_T *grp, char *type_name)
|
||||
nc_type ud_type_type = NC_NAT, base_nc_type = NC_NAT, member_xtype;
|
||||
htri_t ret;
|
||||
int retval = NC_NOERR;
|
||||
void *value;
|
||||
void *value = NULL;
|
||||
int i;
|
||||
|
||||
assert(grp && type_name);
|
||||
@ -1224,12 +1227,16 @@ read_type(NC_GRP_INFO_T *grp, char *type_name)
|
||||
|
||||
/* Read each name and value defined in the enum. */
|
||||
for (i = 0; i < type->num_enum_members; i++)
|
||||
{
|
||||
/* Get the name and value from HDF5. */
|
||||
if (!(member_name = H5Tget_member_name(hdf_typeid, i)))
|
||||
return NC_EHDFERR;
|
||||
if (!member_name || strlen(member_name) > NC_MAX_NAME)
|
||||
return NC_EBADNAME;
|
||||
{
|
||||
/* Get the name and value from HDF5. */
|
||||
if (!(member_name = H5Tget_member_name(hdf_typeid, i))) {
|
||||
if(value) free(value);
|
||||
return NC_EHDFERR;
|
||||
}
|
||||
if (!member_name || strlen(member_name) > NC_MAX_NAME) {
|
||||
if(value) free(value);
|
||||
return NC_EBADNAME;
|
||||
}
|
||||
if (H5Tget_member_value(hdf_typeid, i, value) < 0)
|
||||
return NC_EHDFERR;
|
||||
|
||||
|
@ -286,10 +286,10 @@ get_fill_value(NC_HDF5_FILE_INFO_T *h5, NC_VAR_INFO_T *var, void **fillp)
|
||||
}
|
||||
else if (var->xtype == NC_STRING)
|
||||
{
|
||||
if (!(*(char **)fillp = malloc((strlen((char *)var->fill_value) + 1) *
|
||||
sizeof(char))))
|
||||
return NC_ENOMEM;
|
||||
strcpy(*(char **)fillp, (char *)var->fill_value);
|
||||
if (!(*(char **)fillp = malloc((strlen((char *)var->fill_value) + 1) *
|
||||
sizeof(char))))
|
||||
return NC_ENOMEM;
|
||||
strcpy(*(char **)fillp, (char *)var->fill_value);
|
||||
}
|
||||
else
|
||||
memcpy((*fillp), var->fill_value, size);
|
||||
@ -1543,6 +1543,7 @@ var_create_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, int write_dimid)
|
||||
if (maxdimsize) free(maxdimsize);
|
||||
if (dimsize) free(dimsize);
|
||||
if (chunksize) free(chunksize);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user