From 03feb61043064dfa8bb398bd6fb58c11904fc077 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Sun, 28 Jun 2020 21:33:35 +0100 Subject: [PATCH] ECC-1127: Crash: Trying to print expandedOriginalCodes with bufr_ls --- src/grib_accessor_class_smart_table.c | 7 +++++++ 1 file changed, 7 insertions(+) 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];