pool: Proper cleanup in error cases when adding addresses from a file.

This commit is contained in:
Tobias Brunner 2011-04-19 12:55:58 +02:00
parent e5143952f0
commit 00b9f755f8
1 changed files with 6 additions and 0 deletions

View File

@ -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;