mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-03-01 17:06:03 +08:00
Resource leak, Coverity 1264409
This commit is contained in:
parent
64e69f26f3
commit
cb0cb6f674
14
oc2/oc.c
14
oc2/oc.c
@ -53,12 +53,15 @@ OCerror
|
|||||||
oc_open(const char* url, OCobject* linkp)
|
oc_open(const char* url, OCobject* linkp)
|
||||||
{
|
{
|
||||||
OCerror ocerr;
|
OCerror ocerr;
|
||||||
OCstate* state;
|
OCstate* state = NULL;
|
||||||
if(!ocglobalstate.initialized) oc_initialize();
|
if(!ocglobalstate.initialized) oc_initialize();
|
||||||
ocerr = ocopen(&state,url);
|
ocerr = ocopen(&state,url);
|
||||||
if(ocerr == OC_NOERR && linkp) {
|
if(ocerr == OC_NOERR && linkp) {
|
||||||
*linkp = (OCobject)(state);
|
*linkp = (OCobject)(state);
|
||||||
|
} else {
|
||||||
|
if(state) free(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OCTHROW(ocerr);
|
return OCTHROW(ocerr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2137,7 +2140,7 @@ oc_set_rcfile(const char* rcfile)
|
|||||||
ocinternalinitialize(); /* so ocglobalstate is defined, but not triplestore */
|
ocinternalinitialize(); /* so ocglobalstate is defined, but not triplestore */
|
||||||
if(rcfile == NULL) {
|
if(rcfile == NULL) {
|
||||||
ocglobalstate.rc.ignore = 1;
|
ocglobalstate.rc.ignore = 1;
|
||||||
} else {
|
} else {
|
||||||
FILE* f = fopen(rcfile,"r");
|
FILE* f = fopen(rcfile,"r");
|
||||||
if(f == NULL) {
|
if(f == NULL) {
|
||||||
stat = (OC_ERCFILE);
|
stat = (OC_ERCFILE);
|
||||||
@ -2146,7 +2149,7 @@ oc_set_rcfile(const char* rcfile)
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
ocglobalstate.rc.rcfile = strdup(rcfile);
|
ocglobalstate.rc.rcfile = strdup(rcfile);
|
||||||
/* (re) load the rcfile and esp the triplestore*/
|
/* (re) load the rcfile and esp the triplestore*/
|
||||||
stat = ocrc_load();
|
stat = ocrc_load();
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
return OCTHROW(stat);
|
return OCTHROW(stat);
|
||||||
@ -2183,9 +2186,8 @@ oc_initialize(void)
|
|||||||
ocglobalstate.initialized = 0;
|
ocglobalstate.initialized = 0;
|
||||||
status = ocinternalinitialize();
|
status = ocinternalinitialize();
|
||||||
/* (re) load the rcfile */
|
/* (re) load the rcfile */
|
||||||
status = ocrc_load();
|
status = ocrc_load();
|
||||||
return OCTHROW(status);
|
return OCTHROW(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user