From 00b9f755f8c43a2f81bcd0f6db142780956a283f Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Tue, 19 Apr 2011 12:55:58 +0200 Subject: pool: Proper cleanup in error cases when adding addresses from a file. --- src/libhydra/plugins/attr_sql/pool.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/libhydra/plugins/attr_sql/pool.c b/src/libhydra/plugins/attr_sql/pool.c index 0ef41a7bd..820479e1c 100644 --- a/src/libhydra/plugins/attr_sql/pool.c +++ b/src/libhydra/plugins/attr_sql/pool.c @@ -411,6 +411,7 @@ static bool add_address(u_int pool_id, char *address_str, int *family) *family != address->get_family(address)) { fprintf(stderr, "invalid address family '%s'.\n", address_str); + address->destroy(address); return FALSE; } @@ -422,6 +423,7 @@ static bool add_address(u_int pool_id, char *address_str, int *family) DB_UINT, user_id, DB_UINT, 0, DB_UINT, 1) != 1) { fprintf(stderr, "inserting address '%s' failed.\n", address_str); + address->destroy(address); return FALSE; } if (family) @@ -473,6 +475,10 @@ static void add_addresses(char *pool, char *path, int timeout) } if (add_address(pool_id, address_str, &family) == FALSE) { + if (file != stdin) + { + fclose(file); + } exit(EXIT_FAILURE); } ++count; -- cgit v1.2.3