Blob Blame History Raw
autofs-5.0.7 - fix memory leak in get_dc_list()

From: Ian Kent <raven@themaw.net>

In get_dc_list() if an invalid port is found the allocated list storage
isn't freed on the error exit.
---
 modules/dclist.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/modules/dclist.c b/modules/dclist.c
index d16b913..af21ce0 100644
--- a/modules/dclist.c
+++ b/modules/dclist.c
@@ -536,6 +536,7 @@ struct dclist *get_dc_list(unsigned int logopt, const char *uri)
 		else
 			strcat(tmp, " ");
 
+		list = NULL;
 		for (i = 0; i < numdcs; i++) {
 			if (i > 0)
 				strcat(tmp, " ");
@@ -549,6 +550,7 @@ struct dclist *get_dc_list(unsigned int logopt, const char *uri)
 					error(logopt,
 					      "invalid port: %u", dcs[i].port);
 					free_srv_rrs(dcs, numdcs);
+					free(tmp);
 					goto out_error;
 				}
 				strcat(tmp, port);