@@ -1839,19 +1839,16 @@ NC_create(const char *path0, int cmode, size_t initialsz,
18391839
18401840 TRACE (nc_create );
18411841 if (path0 == NULL )
1842- return NC_EINVAL ;
1842+ { stat = NC_EINVAL ; goto done ;}
18431843
18441844 /* Check mode flag for sanity. */
1845- if ((stat = check_create_mode (cmode )))
1846- return stat ;
1845+ if ((stat = check_create_mode (cmode ))) goto done ;
18471846
18481847 /* Initialize the library. The available dispatch tables
18491848 * will depend on how netCDF was built
18501849 * (with/without netCDF-4, DAP, CDMREMOTE). */
1851- if (!NC_initialized )
1852- {
1853- if ((stat = nc_initialize ()))
1854- return stat ;
1850+ if (!NC_initialized ) {
1851+ if ((stat = nc_initialize ())) goto done ;
18551852 }
18561853
18571854 {
@@ -1863,10 +1860,7 @@ NC_create(const char *path0, int cmode, size_t initialsz,
18631860
18641861 memset (& model ,0 ,sizeof (model ));
18651862 newpath = NULL ;
1866- if ((stat = NC_infermodel (path ,& cmode ,1 ,useparallel ,NULL ,& model ,& newpath ))) {
1867- nullfree (newpath );
1868- goto done ;
1869- }
1863+ if ((stat = NC_infermodel (path ,& cmode ,1 ,useparallel ,NULL ,& model ,& newpath ))) goto done ;
18701864 if (newpath ) {
18711865 nullfree (path );
18721866 path = newpath ;
@@ -1918,7 +1912,7 @@ NC_create(const char *path0, int cmode, size_t initialsz,
19181912 dispatcher = NC3_dispatch_table ;
19191913 break ;
19201914 default :
1921- return NC_ENOTNC ;
1915+ { stat = NC_ENOTNC ; goto done ;}
19221916 }
19231917
19241918 /* Create the NC* instance and insert its dispatcher and model */
@@ -1937,6 +1931,7 @@ NC_create(const char *path0, int cmode, size_t initialsz,
19371931 }
19381932done :
19391933 nullfree (path );
1934+ nullfree (newpath );
19401935 return stat ;
19411936}
19421937
@@ -1980,12 +1975,12 @@ NC_open(const char *path0, int omode, int basepe, size_t *chunksizehintp,
19801975 TRACE (nc_open );
19811976 if (!NC_initialized ) {
19821977 stat = nc_initialize ();
1983- if (stat ) return stat ;
1978+ if (stat ) goto done ;
19841979 }
19851980
19861981 /* Check inputs. */
19871982 if (!path0 )
1988- return NC_EINVAL ;
1983+ { stat = NC_EINVAL ; goto done ;}
19891984
19901985 /* Capture the inmemory related flags */
19911986 mmap = ((omode & NC_MMAP ) == NC_MMAP );
0 commit comments