mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-02-17 16:50:18 +08:00
Addressed a handful of coverity-reported issues.
This commit is contained in:
parent
62fff7ae57
commit
746ddd0390
@ -327,8 +327,10 @@ memio_open(const char* path,
|
||||
filesize = (off_t)sizehint;
|
||||
|
||||
status = memio_new(path, ioflags, filesize, &nciop, &memio);
|
||||
if(status != NC_NOERR)
|
||||
return status;
|
||||
if(status != NC_NOERR) {
|
||||
if(fd > 0) close(fd);
|
||||
return status;
|
||||
}
|
||||
memio->size = filesize;
|
||||
|
||||
memio->memory = (char*)malloc(memio->alloc);
|
||||
|
@ -848,7 +848,7 @@ int
|
||||
nc4_enum_member_add(NC_ENUM_MEMBER_INFO_T **list, size_t size,
|
||||
const char *name, const void *value)
|
||||
{
|
||||
NC_ENUM_MEMBER_INFO_T *member, *m;
|
||||
NC_ENUM_MEMBER_INFO_T *member = NULL, *m = NULL;
|
||||
|
||||
/* Name has already been checked. */
|
||||
assert(name && size > 0 && value);
|
||||
@ -874,8 +874,11 @@ nc4_enum_member_add(NC_ENUM_MEMBER_INFO_T **list, size_t size,
|
||||
}
|
||||
|
||||
/* Store the information about this member. */
|
||||
if (!(member->name = malloc((strlen(name) + 1) * sizeof(char))))
|
||||
return NC_ENOMEM;
|
||||
if (!(member->name = malloc((strlen(name) + 1) * sizeof(char)))) {
|
||||
if(member) free(member);
|
||||
|
||||
return NC_ENOMEM;
|
||||
}
|
||||
strcpy(member->name, name);
|
||||
memcpy(member->value, value, size);
|
||||
|
||||
|
@ -250,7 +250,8 @@ genbin_deftype(Symbol* tsym)
|
||||
&tsym->ncid);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
break;
|
||||
case NC_ENUM: {
|
||||
case NC_ENUM:
|
||||
{
|
||||
Bytebuffer* datum;
|
||||
Datalist* ecdl;
|
||||
stat = nc_def_enum(tsym->container->ncid,
|
||||
@ -263,19 +264,21 @@ genbin_deftype(Symbol* tsym)
|
||||
dlextend(ecdl); /* make room for one constant*/
|
||||
ecdl->length = 1;
|
||||
for(i=0;i<listlength(tsym->subnodes);i++) {
|
||||
Symbol* econst = (Symbol*)listget(tsym->subnodes,i);
|
||||
ASSERT(econst->subclass == NC_ECONST);
|
||||
generator_reset(bin_generator,NULL);
|
||||
bbClear(datum);
|
||||
generate_basetype(econst->typ.basetype,&econst->typ.econst,datum,NULL,bin_generator);
|
||||
stat = nc_insert_enum(tsym->container->ncid,
|
||||
tsym->ncid,
|
||||
econst->name,
|
||||
bbContents(datum));
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
Symbol* econst = (Symbol*)listget(tsym->subnodes,i);
|
||||
ASSERT(econst->subclass == NC_ECONST);
|
||||
generator_reset(bin_generator,NULL);
|
||||
bbClear(datum);
|
||||
generate_basetype(econst->typ.basetype,&econst->typ.econst,datum,NULL,bin_generator);
|
||||
stat = nc_insert_enum(tsym->container->ncid,
|
||||
tsym->ncid,
|
||||
econst->name,
|
||||
bbContents(datum));
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
}
|
||||
bbFree(datum);
|
||||
} break;
|
||||
|
||||
}
|
||||
break;
|
||||
case NC_VLEN:
|
||||
stat = nc_def_vlen(tsym->container->ncid,
|
||||
tsym->name,
|
||||
|
@ -110,6 +110,7 @@ gen_ncc(const char *filename)
|
||||
codedump(tmp);
|
||||
codeline("} ;");
|
||||
}
|
||||
bbFree(tmp);
|
||||
}
|
||||
codeline("");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user