Properly handle situation if no resolver plugins are loaded
authorTobias Brunner <tobias@strongswan.org>
Mon, 1 Apr 2013 11:44:04 +0000 (13:44 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 1 Apr 2013 11:44:04 +0000 (13:44 +0200)
src/libcharon/plugins/ipseckey/ipseckey_plugin.c
src/libstrongswan/resolver/resolver_manager.c

index 6f0f105..7de842d 100644 (file)
@@ -60,7 +60,7 @@ METHOD(plugin_t, destroy, void,
        {
                lib->credmgr->remove_set(lib->credmgr, &this->cred->set);
        }
-       this->res->destroy(this->res);
+       DESTROY_IF(this->res);
        DESTROY_IF(this->cred);
        free(this);
 }
@@ -87,8 +87,7 @@ plugin_t *ipseckey_plugin_create()
 
        if (!this->res)
        {
-               DBG1(DBG_CFG, "ipseckey_plugin: Failed to create"
-                                         "a DNS resolver instance");
+               DBG1(DBG_CFG, "failed to create a DNS resolver instance");
                destroy(this);
                return NULL;
        }
index 8effe46..55531e1 100644 (file)
@@ -56,7 +56,11 @@ METHOD(resolver_manager_t, remove_resolver, void,
 METHOD(resolver_manager_t, create, resolver_t*,
        private_resolver_manager_t *this)
 {
-       return this->constructor();
+       if (this->constructor)
+       {
+               return this->constructor();
+       }
+       return NULL;
 }
 
 METHOD(resolver_manager_t, destroy, void,