Fortran: any_f_scan_file_ check for errors

This commit is contained in:
Shahram Najm 2024-01-02 16:04:02 +00:00
parent 4047c5764c
commit 4cd68b210f
1 changed files with 29 additions and 22 deletions

View File

@ -1468,7 +1468,14 @@ int any_f_new_from_scanned_file_(int* fid,int* msgid,int* gid)
int err = 0;
FILE* f = get_file(*fid);
/* fortran convention of 1 based index*/
if (info_messages == NULL) {
return GRIB_INVALID_ARGUMENT;
}
if (*msgid < 1 || *msgid > info_messages->n) {
return GRIB_INVALID_ARGUMENT;
}
/* fortran convention of 1-based index */
const int n = *msgid - 1;
l_message_info* msg=(l_message_info*)grib_oarray_get(info_messages, n);