From ca14e1521e52981d94fbd35d7e8fcbc32c45fa50 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Wed, 12 Jun 2024 13:21:49 -0700 Subject: [PATCH] lib/ec_glob: plug leak of nums utarray --- src/lib/ec_glob.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/ec_glob.c b/src/lib/ec_glob.c index c2b83cf..9bfaf9e 100644 --- a/src/lib/ec_glob.c +++ b/src/lib/ec_glob.c @@ -53,16 +53,20 @@ static const UT_icd ut_int_pair_icd = {sizeof(int_pair),NULL,NULL,NULL}; #define STRING_CAT(p, string, end) do { \ size_t string_len = strlen(string); \ assert(end > p); \ - if (string_len >= (size_t)(end - p)) \ + if (string_len >= (size_t)(end - p)) { \ + utarray_free(nums); \ return -1; \ + } \ strcat(p, string); \ p += string_len; \ } while(0) /* safely add a char to a string then move the pointer to the end */ #define ADD_CHAR(string, new_chr, end) do { \ - if (string + 1 >= end) \ + if (string + 1 >= end) { \ + utarray_free(nums); \ return -1; \ + } \ *(string ++) = new_chr; \ } while(0)