From 095eff61e21fccf73658b23411a6092b8105ecd4 Mon Sep 17 00:00:00 2001 From: shahramn Date: Tue, 22 Oct 2024 11:12:10 +0100 Subject: [PATCH] Geoiterators: Initialise lats_ and lons_ (fix valgrind error) --- src/geo_iterator/grib_iterator_class_gen.cc | 2 ++ src/geo_iterator/grib_iterator_class_regular.cc | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/geo_iterator/grib_iterator_class_gen.cc b/src/geo_iterator/grib_iterator_class_gen.cc index cf63d0ce4..4ee02d007 100644 --- a/src/geo_iterator/grib_iterator_class_gen.cc +++ b/src/geo_iterator/grib_iterator_class_gen.cc @@ -15,6 +15,8 @@ namespace eccodes::geo_iterator { int Gen::init(grib_handle* h, grib_arguments* args) { int err = GRIB_SUCCESS; + lats_ = lons_ = NULL; + if ((err = Iterator::init(h, args)) != GRIB_SUCCESS) return err; diff --git a/src/geo_iterator/grib_iterator_class_regular.cc b/src/geo_iterator/grib_iterator_class_regular.cc index 0b1865c7c..98b58050c 100644 --- a/src/geo_iterator/grib_iterator_class_regular.cc +++ b/src/geo_iterator/grib_iterator_class_regular.cc @@ -51,15 +51,15 @@ int Regular::destroy() const grib_context* c = h_->context; grib_context_free(c, lats_); grib_context_free(c, lons_); + lats_ = lons_ = NULL; return Gen::destroy(); } int Regular::init(grib_handle* h, grib_arguments* args) { - int ret = GRIB_SUCCESS; - if ((ret = Gen::init(h, args)) != GRIB_SUCCESS) - return ret; + int ret = Gen::init(h, args); + if (ret != GRIB_SUCCESS) return ret; long Ni; /* Number of points along a parallel = Nx */ long Nj; /* Number of points along a meridian = Ny */