Skip to content

Commit

Permalink
ECC-782: Multi-field GRIB: crash in grib_handle_new_from_file_multi
Browse files Browse the repository at this point in the history
  • Loading branch information
shahramn committed May 16, 2024
1 parent a299e60 commit bfd47cf
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/grib_handle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,6 @@ static grib_handle* grib_handle_new_multi(grib_context* c, unsigned char** data,
while (grib2_get_next_section((unsigned char*)message, olen, &secbegin, &seclen, &secnum, &err)) {
// seccount++;
/*printf(" - %d - section %d length=%d\n",(int)seccount,(int)secnum,(int)seclen);*/

gm->sections[secnum] = secbegin;
gm->sections_length[secnum] = seclen;

Expand Down Expand Up @@ -686,6 +685,11 @@ static grib_handle* grib_handle_new_multi(grib_context* c, unsigned char** data,
break;
}
}
// ECC-782
if (err == GRIB_INVALID_SECTION_NUMBER) {
grib_context_log(c, GRIB_LOG_ERROR, "%s: Failed to get section info (%s)", __func__, grib_get_error_message(err));
return NULL;
}
}
else if (edition == 3) {
*error = GRIB_UNSUPPORTED_EDITION;
Expand Down Expand Up @@ -840,6 +844,11 @@ static grib_handle* grib_handle_new_from_file_multi(grib_context* c, FILE* f, in
break;
}
}
// ECC-782
if (err == GRIB_INVALID_SECTION_NUMBER) {
grib_context_log(c, GRIB_LOG_ERROR, "%s: Failed to get section info (%s)", __func__, grib_get_error_message(err));
return NULL;
}
}
else if (edition == 3) {
/* GRIB3: Multi-field mode not yet supported */
Expand Down

0 comments on commit bfd47cf

Please sign in to comment.