aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2011-04-19 12:55:58 +0200
committerTobias Brunner <tobias@strongswan.org>2011-04-19 13:48:50 +0200
commit00b9f755f8c43a2f81bcd0f6db142780956a283f (patch)
tree0fd2af3b0bdf19f1b1f5f7a5e1818aaa8984c8ab /src
parente5143952f0dde2d5694f5ca70140d2b1781ff516 (diff)
downloadstrongswan-00b9f755f8c43a2f81bcd0f6db142780956a283f.tar.bz2
strongswan-00b9f755f8c43a2f81bcd0f6db142780956a283f.tar.xz
pool: Proper cleanup in error cases when adding addresses from a file.
Diffstat (limited to 'src')
-rw-r--r--src/libhydra/plugins/attr_sql/pool.c6
1 files changed, 6 insertions, 0 deletions
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;