ECC-1338: Fortran: call to fclose() should check the return value

This commit is contained in:
Shahram Najm 2022-02-03 13:31:01 +00:00
parent 5e9c715b05
commit bc36885685
1 changed files with 10 additions and 1 deletions

View File

@ -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;
}