fixed memory leaks in nc_open()
@@ -1883,11 +1883,16 @@ NC_open(const char *path0, int cmode,
if(diskless) flags |= NC_DISKLESS;
stat = NC_check_file_type(path,flags,parameters,&model,&version);
if(stat == NC_NOERR) {
- if(model == 0)
+ if(model == 0) {
+ nullfree(path);
return NC_ENOTNC;
- } else /* presumably not a netcdf file */
+ }
+ } else {
+ /* presumably not a netcdf file */
+ nullfree(path);
return stat;
}
+ }
if(model == 0) {
fprintf(stderr,"Model == 0\n");
@@ -1959,13 +1964,17 @@ NC_open(const char *path0, int cmode,
#endif
if(model == (NC_FORMATX_NC3))
dispatcher = NC3_dispatch_table;
- else
+ else {
+ nullfree(path);
return NC_ENOTNC;
+ }
havetable:
- if(dispatcher == NULL)
+ if(dispatcher == NULL) {
+ nullfree(path);
return NC_ENOTNC;
+ }
/* Create the NC* instance and insert its dispatcher */
stat = new_NC(dispatcher,path,cmode,&ncp);
