]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
pool: Proper cleanup in error cases when adding addresses from a file.
authorTobias Brunner <tobias@strongswan.org>
Tue, 19 Apr 2011 10:55:58 +0000 (12:55 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 19 Apr 2011 11:48:50 +0000 (13:48 +0200)
src/libhydra/plugins/attr_sql/pool.c

index 0ef41a7bd3b8789dc7d4fae8ceffba91aee57704..820479e1cab05c54caea515c48f92aee438c8c90 100644 (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;