diff --git a/src/grib_accessor_class_smart_table.c b/src/grib_accessor_class_smart_table.c index 70fa29a6e..5d2318ad7 100644 --- a/src/grib_accessor_class_smart_table.c +++ b/src/grib_accessor_class_smart_table.c @@ -571,6 +571,13 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) if (err) return 0; + if (*len < self->tableCodesSize) { + grib_context_log(a->context, GRIB_LOG_ERROR, + " wrong size (%ld) for %s it contains %d values ", *len, a->name, self->tableCodesSize); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + for (i = 0; i < self->tableCodesSize; i++) val[i] = self->tableCodes[i];