diff options
author | Yann Ylavic <ylavic@apache.org> | 2021-09-10 00:17:24 +0000 |
---|---|---|
committer | Yann Ylavic <ylavic@apache.org> | 2021-09-10 00:17:24 +0000 |
commit | 163521ebfaa78bec639897b3c4d3bdcd35a9cd1c (patch) | |
tree | d84b38503b848ea21e9d127ea06ffd8c82fbf829 /test/abts.c | |
parent | 398fc32f2930640777aa1afc3417d73c4f3afc48 (diff) | |
download | apr-163521ebfaa78bec639897b3c4d3bdcd35a9cd1c.tar.gz |
test: fix memory leaks of the test framework at exit.
To please memory leak analysers..
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1893202 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/abts.c')
-rw-r--r-- | test/abts.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/test/abts.c b/test/abts.c index 3c5660fc2..8d651797b 100644 --- a/test/abts.c +++ b/test/abts.c @@ -125,7 +125,7 @@ abts_suite *abts_add_suite(abts_suite *suite, const char *suite_name_full) suite_name, p - suite_name); } else { - subsuite->name = suite_name; + subsuite->name = strdup(suite_name); } if (list_tests) { @@ -157,6 +157,21 @@ abts_suite *abts_add_suite(abts_suite *suite, const char *suite_name_full) return suite; } +static void abts_free_suite(abts_suite *suite) +{ + if (suite) { + sub_suite *dptr, *next; + + for (dptr = suite->head; dptr; dptr = next) { + next = dptr->next; + free(dptr->name); + free(dptr); + } + + free(suite); + } +} + void abts_run_test(abts_suite *ts, test_func f, void *value) { abts_case tc; @@ -483,6 +498,7 @@ int main(int argc, const char *const argv[]) { } rv = report(suite); + abts_free_suite(suite); return rv; } |