mirror of https://github.com/ecmwf/eccodes.git
ECC-1338: Fortran: call to fclose() should check the return value
This commit is contained in:
parent
5e9c715b05
commit
bc36885685
|
@ -750,11 +750,20 @@ static bufr_keys_iterator* get_bufr_keys_iterator(int keys_iterator_id)
|
|||
|
||||
static int clear_file(int file_id)
|
||||
{
|
||||
int err = 0;
|
||||
l_grib_file* current = file_set;
|
||||
while(current){
|
||||
if(current->id == file_id){
|
||||
current->id = -(current->id);
|
||||
if (current->f) fclose(current->f);
|
||||
if (current->f) {
|
||||
err = fclose(current->f);
|
||||
if (err) {
|
||||
int ioerr = errno;
|
||||
grib_context* c = grib_context_get_default();
|
||||
grib_context_log(c,(GRIB_LOG_ERROR)|(GRIB_LOG_PERROR),"IO ERROR: %s",strerror(ioerr));
|
||||
return GRIB_IO_PROBLEM;
|
||||
}
|
||||
}
|
||||
if (current->buffer) free(current->buffer);
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue