]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon: fixed potential leak - cleanup not being called on longjmp
authorMarek Vavruša <mvavrusa@cloudflare.com>
Thu, 18 Jan 2018 00:39:37 +0000 (16:39 -0800)
committerMarek Vavruša <mvavrusa@cloudflare.com>
Thu, 18 Jan 2018 00:54:33 +0000 (16:54 -0800)
attribute cleanup (auto_free) gets called when variable goes out of
scope, not on longjmp (in lua_error), so the variable never gets freed

daemon/bindings.c

index 9da6f0f56d55f0bd40858fb6e1694747574ec560..46aaa8c504a71c566c6d2095aaf027ef522596f2 100644 (file)
@@ -85,7 +85,7 @@ static int mod_load(lua_State *L)
                lua_error(L);
        }
        /* Parse precedence declaration */
-       auto_free char *declaration = strdup(lua_tostring(L, 1));
+       char *declaration = strdup(lua_tostring(L, 1));
        if (!declaration) {
                return kr_error(ENOMEM);
        }
@@ -95,6 +95,7 @@ static int mod_load(lua_State *L)
        /* Load engine module */
        struct engine *engine = engine_luaget(L);
        int ret = engine_register(engine, name, precedence, ref);
+       free(declaration);
        if (ret != 0) {
                if (ret == kr_error(EIDRM)) {
                        format_error(L, "referenced module not found");