From d0f68666e6abb438700f20951a40b90bebb54dce Mon Sep 17 00:00:00 2001 From: shahramn Date: Wed, 6 Mar 2024 10:25:42 +0000 Subject: [PATCH] ECC-1781: Further cleanup --- src/grib_nearest_class_latlon_reduced.cc | 2 +- src/grib_nearest_class_reduced.cc | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/grib_nearest_class_latlon_reduced.cc b/src/grib_nearest_class_latlon_reduced.cc index a5d2af222..e5c503e99 100644 --- a/src/grib_nearest_class_latlon_reduced.cc +++ b/src/grib_nearest_class_latlon_reduced.cc @@ -214,7 +214,7 @@ static int find_global(grib_nearest* nearest, grib_handle* h, return ret; } while (grib_iterator_next(iter, &lat, &lon, NULL)) { - if (olat != lat) { + if (ilat < self->lats_count && olat != lat) { self->lats[ilat++] = lat; olat = lat; } diff --git a/src/grib_nearest_class_reduced.cc b/src/grib_nearest_class_reduced.cc index f17d3b4e3..ef0e25c5b 100644 --- a/src/grib_nearest_class_reduced.cc +++ b/src/grib_nearest_class_reduced.cc @@ -251,7 +251,7 @@ static int find_global(grib_nearest* nearest, grib_handle* h, return err; } while (grib_iterator_next(iter, &lat, &lon, NULL)) { - if (olat != lat) { + if (ilat < self->lats_count && olat != lat) { self->lats[ilat++] = lat; olat = lat; } @@ -262,6 +262,7 @@ static int find_global(grib_nearest* nearest, grib_handle* h, if (lon > 180 && lon < 360) lon -= 360; } + DEBUG_ASSERT_ACCESS(self->lons, (long)ilon, (long)nearest->values_count); self->lons[ilon++] = lon; } self->lats_count = ilat;