From 37000b024574d78b1313168443fd110b09c6d85b Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 18 Mar 2016 17:14:15 -0400 Subject: [PATCH] libsupport: fix potential resource leaks in the profile code These were found by Coverity. Signed-off-by: Theodore Ts'o --- lib/support/profile_helpers.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/support/profile_helpers.c b/lib/support/profile_helpers.c index 9c9080a..a174784 100644 --- a/lib/support/profile_helpers.c +++ b/lib/support/profile_helpers.c @@ -153,7 +153,7 @@ profile_get_values(profile_t profile, const char *const *names, return retval; if ((retval = init_list(&values))) - return retval; + goto cleanup_iterator; do { if ((retval = profile_iterator(&state, 0, &value))) @@ -172,6 +172,8 @@ profile_get_values(profile_t profile, const char *const *names, cleanup: end_list(&values, 0); +cleanup_iterator: + profile_iterator_free(&state); return retval; } @@ -194,7 +196,7 @@ profile_get_subsection_names(profile_t profile, const char **names, return retval; if ((retval = init_list(&values))) - return retval; + goto cleanup_iterator; do { if ((retval = profile_iterator(&state, &name, 0))) @@ -208,6 +210,8 @@ profile_get_subsection_names(profile_t profile, const char **names, cleanup: end_list(&values, 0); +cleanup_iterator: + profile_iterator_free(&state); return retval; } @@ -230,7 +234,7 @@ profile_get_relation_names(profile_t profile, const char **names, return retval; if ((retval = init_list(&values))) - return retval; + goto cleanup_iterator; do { if ((retval = profile_iterator(&state, &name, 0))) @@ -248,6 +252,8 @@ profile_get_relation_names(profile_t profile, const char **names, cleanup: end_list(&values, 0); +cleanup_iterator: + profile_iterator_free(&state); return retval; } -- 1.8.3.1