Skip to content
Snippets Groups Projects
Commit 584b04bf authored by Marek Vavruša's avatar Marek Vavruša
Browse files

daemon: fixed potential leak - cleanup not being called on longjmp

attribute cleanup (auto_free) gets called when variable goes out of
scope, not on longjmp (in lua_error), so the variable never gets freed
parent 1286086c
No related branches found
No related tags found
1 merge request!446fix some errors found by static analyzer
......@@ -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");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment