From 5fbf431c4252b8c71e6bfff16339f6b95f2d56e7 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 30 Jun 2023 19:08:04 -0600 Subject: [PATCH] Fix a few memory leaks in the tests. --- plugins/sudoers/regress/exptilde/check_exptilde.c | 7 ++----- plugins/sudoers/testsudoers.c | 1 + 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/sudoers/regress/exptilde/check_exptilde.c b/plugins/sudoers/regress/exptilde/check_exptilde.c index 94746c23b..8ed39670c 100644 --- a/plugins/sudoers/regress/exptilde/check_exptilde.c +++ b/plugins/sudoers/regress/exptilde/check_exptilde.c @@ -74,7 +74,6 @@ main(int argc, char *argv[]) for (td = test_data; td->input != NULL; td++) { ntests++; - free(path); if ((path = strdup(td->input)) == NULL) sudo_fatal(NULL); result = expand_tilde(&path, td->user); @@ -86,14 +85,12 @@ main(int argc, char *argv[]) } else { sudo_warnx("unexpected failure: input %s", td->input); } - continue; - } - if (td->result && strcmp(path, td->output) != 0) { + } else if (td->result && strcmp(path, td->output) != 0) { errors++; sudo_warnx("incorrect output for input %s: expected %s, got %s", td->input, td->output, path); - continue; } + free(path); } if (ntests != 0) { diff --git a/plugins/sudoers/testsudoers.c b/plugins/sudoers/testsudoers.c index 1bb7d8862..daaf21339 100644 --- a/plugins/sudoers/testsudoers.c +++ b/plugins/sudoers/testsudoers.c @@ -295,6 +295,7 @@ main(int argc, char *argv[]) if (get_net_ifs(&p) > 0) { if (!set_interfaces(p)) sudo_fatal("%s", U_("unable to parse network address list")); + free(p); } /* Initialize the parser and set sudoers filename to "sudoers". */