Blob Blame History Raw
autofs-5.1.0 - fix memory leak in get_defaults_entry()

From: Ian Kent <ikent@redhat.com>

In get_defaults_entry(), if parsing of the expanded defaults string fails
the expanded string used for the parse is not freed.
---
 CHANGELOG           |    1 +
 modules/parse_amd.c |    4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG b/CHANGELOG
index 2bb0500..439a51f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -25,6 +25,7 @@
 - fix hosts map options check in lookup_amd_instance().
 - fix memory leak in create_client().
 - fix memory leak in get_exports().
+- fix memory leak in get_defaults_entry().
 
 04/06/2014 autofs-5.1.0
 =======================
diff --git a/modules/parse_amd.c b/modules/parse_amd.c
index a912385..ebf3807 100644
--- a/modules/parse_amd.c
+++ b/modules/parse_amd.c
@@ -1797,8 +1797,10 @@ static struct amd_entry *get_defaults_entry(struct autofs_point *ap,
 		char *expand;
 		if (!expand_selectors(ap, defaults, &expand, sv))
 			goto out;
-		if (amd_parse_list(ap, expand, &dflts, &sv))
+		if (amd_parse_list(ap, expand, &dflts, &sv)) {
+			free(expand);
 			goto out;
+		}
 		entry = select_default_entry(ap, &dflts, sv);
 		if (!entry->map_type) {
 			/*