]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
kr_module_load(): avoid calling deinit() on errors
authorVladimír Čunát <vladimir.cunat@nic.cz>
Fri, 20 Dec 2024 12:27:41 +0000 (13:27 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Fri, 20 Dec 2024 12:27:41 +0000 (13:27 +0100)
If the module's init() failed or wasn't even called,
I see it as an API error to call deinit().
When init() fails, it should take care of cleanup itself.

lib/module.c

index 79219d3a108949a1d296a69aca5928b085de5aba..2427c7b6c32c6f6cc355694dd57e4b5532a79cb6 100644 (file)
@@ -123,6 +123,8 @@ int kr_module_load(struct kr_module *module, const char *name, const char *path)
                ret = module->init(module);
        }
        if (ret != 0) {
+               /* Avoid calling deinit() as init() wasn't called or failed. */
+               module->deinit = NULL;
                kr_module_unload(module);
        }