From 9b163f5308f70c300f7f2611a1ada41df6be73c5 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 8 Apr 2020 23:02:52 +0100 Subject: [PATCH] Memory leaks --- src/grib_accessor_class_bufr_data_element.c | 1 + src/grib_accessor_class_bufr_elements_table.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/grib_accessor_class_bufr_data_element.c b/src/grib_accessor_class_bufr_data_element.c index a3fa0efca..c332b081f 100644 --- a/src/grib_accessor_class_bufr_data_element.c +++ b/src/grib_accessor_class_bufr_data_element.c @@ -384,6 +384,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) } if (str == 0 || strlen(str) == 0) { + grib_context_free(c, str); *len = 0; *val = 0; return ret; diff --git a/src/grib_accessor_class_bufr_elements_table.c b/src/grib_accessor_class_bufr_elements_table.c index 193c89228..4c6f14e5a 100644 --- a/src/grib_accessor_class_bufr_elements_table.c +++ b/src/grib_accessor_class_bufr_elements_table.c @@ -261,6 +261,8 @@ static grib_trie* load_bufr_elements_table(grib_accessor* a, int* err) dictionary = grib_trie_new(c); while (fgets(line, sizeof(line) - 1, f)) { + DebugAssert( strlen(line) > 0 ); + if (line[0] == '#') continue; list = string_split(line, "|"); grib_trie_insert(dictionary, list[0], list); } @@ -276,6 +278,8 @@ static grib_trie* load_bufr_elements_table(grib_accessor* a, int* err) } while (fgets(line, sizeof(line) - 1, f)) { + DebugAssert( strlen(line) > 0 ); + if (line[0] == '#') continue; list = string_split(line, "|"); grib_trie_insert(dictionary, list[0], list); }