BUFR: Improved error handling

This commit is contained in:
shahramn 2024-11-14 12:16:14 +00:00
parent 1053a594b9
commit 9442493ba3
2 changed files with 6 additions and 2 deletions

View File

@ -181,7 +181,7 @@ void grib_accessor_expanded_descriptors_t::__expand(bufr_descriptors_array* unex
/* Number of descriptors to replicate cannot be more than what's left */ /* Number of descriptors to replicate cannot be more than what's left */
if (us->X + 1 > unexpanded->n) { if (us->X + 1 > unexpanded->n) {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"Delayed replication: %06ld: expected %d but only found %lu elements", "Delayed replication: %06ld: expected %d but only found %lu element(s)",
u->code, us->X, unexpanded->n - 1); u->code, us->X, unexpanded->n - 1);
*err = GRIB_DECODING_ERROR; *err = GRIB_DECODING_ERROR;
return; return;
@ -232,6 +232,10 @@ void grib_accessor_expanded_descriptors_t::__expand(bufr_descriptors_array* unex
grib_bufr_descriptor_delete(u); grib_bufr_descriptor_delete(u);
size = us->X * us->Y; size = us->X * us->Y;
memset(ur, 0, us->X); /* ECC-1422 */ memset(ur, 0, us->X); /* ECC-1422 */
if (us->X > unexpanded->n) {
grib_context_log(c, GRIB_LOG_ERROR, "Replication descriptor %06ld: expected %d but only found %zu element(s)",
us->code, us->X, unexpanded->n);
}
for (j = 0; j < us->X; j++) { for (j = 0; j < us->X; j++) {
DESCRIPTORS_POP_FRONT_OR_RETURN(unexpanded, ur[j]); DESCRIPTORS_POP_FRONT_OR_RETURN(unexpanded, ur[j]);
#if MYDEBUG #if MYDEBUG

View File

@ -24,7 +24,7 @@ status=$?
set -e set -e
[ $status -ne 0 ] [ $status -ne 0 ]
# Check error message # Check error message
grep -q "Delayed replication: 101000: expected 1 but only found 0 elements" $tempError grep -q "Delayed replication: 101000: expected 1 but only found 0 element(s)" $tempError
rm -f $tempFilt $tempError rm -f $tempFilt $tempError