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 */
if (us->X + 1 > unexpanded->n) {
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);
*err = GRIB_DECODING_ERROR;
return;
@ -232,6 +232,10 @@ void grib_accessor_expanded_descriptors_t::__expand(bufr_descriptors_array* unex
grib_bufr_descriptor_delete(u);
size = us->X * us->Y;
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++) {
DESCRIPTORS_POP_FRONT_OR_RETURN(unexpanded, ur[j]);
#if MYDEBUG

View File

@ -24,7 +24,7 @@ status=$?
set -e
[ $status -ne 0 ]
# 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