diff --git a/src/grib_accessor_class_bufr_extract_area_subsets.c b/src/grib_accessor_class_bufr_extract_area_subsets.c index 6de896c93..b3bdec849 100644 --- a/src/grib_accessor_class_bufr_extract_area_subsets.c +++ b/src/grib_accessor_class_bufr_extract_area_subsets.c @@ -313,6 +313,7 @@ static int select_area(grib_accessor* a) if (nsubsets != 0) { subsets_ar = grib_iarray_get_array(subsets); ret = grib_set_long_array(h, self->extractSubsetList, subsets_ar, nsubsets); + grib_context_free(c, subsets_ar); if (ret) return ret; diff --git a/src/grib_accessor_class_bufr_extract_datetime_subsets.c b/src/grib_accessor_class_bufr_extract_datetime_subsets.c index a8dd2ffb0..b4e9642e3 100644 --- a/src/grib_accessor_class_bufr_extract_datetime_subsets.c +++ b/src/grib_accessor_class_bufr_extract_datetime_subsets.c @@ -443,6 +443,7 @@ static int select_datetime(grib_accessor* a) if (nsubsets != 0) { subsets_ar = grib_iarray_get_array(subsets); ret = grib_set_long_array(h, self->extractSubsetList, subsets_ar, nsubsets); + grib_context_free(c, subsets_ar); if (ret) return ret; diff --git a/src/grib_accessor_class_bufr_simple_thinning.c b/src/grib_accessor_class_bufr_simple_thinning.c index 4eb40a384..0cd62f2f4 100644 --- a/src/grib_accessor_class_bufr_simple_thinning.c +++ b/src/grib_accessor_class_bufr_simple_thinning.c @@ -207,6 +207,7 @@ static int apply_thinning(grib_accessor* a) if (nsubsets != 0) { subsets_ar = grib_iarray_get_array(subsets); ret = grib_set_long_array(h, self->extractSubsetList, subsets_ar, nsubsets); + grib_context_free(c, subsets_ar); if (ret) return ret; @@ -218,6 +219,7 @@ static int apply_thinning(grib_accessor* a) if (ret) return ret; } + grib_iarray_delete(subsets); } else { return GRIB_NOT_IMPLEMENTED; diff --git a/src/grib_expression_class_sub_string.c b/src/grib_expression_class_sub_string.c index 1b437fa05..688c663a9 100644 --- a/src/grib_expression_class_sub_string.c +++ b/src/grib_expression_class_sub_string.c @@ -116,14 +116,17 @@ grib_expression* new_sub_string_expression(grib_context* c, const char* value, s if (length == 0) { grib_context_log(c, GRIB_LOG_ERROR, "Invalid substring: length must be > 0"); + grib_context_free_persistent(c, e); return NULL; } if (start > slen) { /* to catch a -ve number passed to start */ grib_context_log(c, GRIB_LOG_ERROR, "Invalid substring: start=%lu", start); + grib_context_free_persistent(c, e); return NULL; } if (start + length > slen) { grib_context_log(c, GRIB_LOG_ERROR, "Invalid substring: start(=%lu)+length(=%lu) > length('%s'))", start, length, value); + grib_context_free_persistent(c, e); return NULL; } diff --git a/src/grib_handle.c b/src/grib_handle.c index 66c509592..5ad87dd2a 100644 --- a/src/grib_handle.c +++ b/src/grib_handle.c @@ -1440,9 +1440,11 @@ grib_action* grib_action_from_filter(const char* filter) grib_action* a = NULL; grib_context* context = grib_context_get_default(); a = grib_parse_file(context, filter); + grib_context_free_persistent(context, context->grib_reader->first->filename); grib_context_free_persistent(context, context->grib_reader->first); grib_context_free_persistent(context, context->grib_reader); + context->grib_reader = NULL; return a; } diff --git a/src/grib_parse_utils.c b/src/grib_parse_utils.c index 0b74b16ef..5c0fa1034 100644 --- a/src/grib_parse_utils.c +++ b/src/grib_parse_utils.c @@ -351,6 +351,7 @@ int grib_accessors_list_print(grib_handle* h, grib_accessors_list* al, const cha *newline = 1; cols = 0; } + grib_context_free(h->context, cvals[i]); } } grib_context_free(h->context, cvals); @@ -485,6 +486,7 @@ int grib_recompose_print(grib_handle* h, grib_accessor* observer, const char* un case ']': loc[mode] = 0; mode = -1; + if(al) grib_accessors_list_delete(h->context, al); al = grib_find_accessors_list(h, loc); /* This allocates memory */ if (!al) { if (!fail) { diff --git a/tests/lsan-leap42.supp b/tests/lsan-leap42.supp index 48b5278e3..c7a7db335 100644 --- a/tests/lsan-leap42.supp +++ b/tests/lsan-leap42.supp @@ -1,7 +1,6 @@ -leak:tools/grib_filter.c -leak:tools/bufr_filter.c -leak:tools/bufr_dump.c +leak:process_elements leak:tools/bufr_compare.c leak:tools/gts_filter.c leak:src/action_class_rename.c leak:tools/grib_to_netcdf.c +leak:tests/bufr_ecc-517.c