# HG changeset patch # User Matti Hamalainen # Date 1587940539 -10800 # Node ID 3ea040bb0dcab6ab5bb76949b23a2991122c8c65 # Parent 838189b856f3fff60217a4002ec754bd68b98768 Fix a memory leak in regex tests. diff -r 838189b856f3 -r 3ea040bb0dca tests.c --- a/tests.c Mon Apr 27 01:31:53 2020 +0300 +++ b/tests.c Mon Apr 27 01:35:39 2020 +0300 @@ -646,6 +646,7 @@ void test_regex_list1(const test_regex_def1 *list, const th_char_t *pattern) { + th_regex_match_t *matches = NULL; th_regex_t *expr = NULL; int res; @@ -665,7 +666,6 @@ for (const test_regex_def1 *def = list; def->str != NULL; def++) { - th_regex_match_t *matches = NULL; size_t nmatches; BOOL matchOK; @@ -675,6 +675,7 @@ { THERR("Regex match returned error: %s\n", th_error_str(res)); + goto out; } @@ -705,9 +706,11 @@ test_regex_list_matches(def->str, matches, def->expected, FALSE); th_regex_free_matches(matches); + matches = NULL; } out: + th_regex_free_matches(matches); th_regex_free(expr); }