lua: readdir: fix double closedir, use one more autofree

The double closedir is a regression from the previous commit, which also
forgot to use the autofree context with the fullpath string.
This commit is contained in:
Avi Halachmi (:avih) 2020-03-22 23:45:06 +02:00
parent 8deffd9fbb
commit 5a2fa3f29a
1 changed files with 1 additions and 3 deletions

View File

@ -1019,7 +1019,7 @@ static int script_readdir(lua_State *L, void *tmp)
}
add_af_dir(tmp, dir);
lua_newtable(L); // list
char *fullpath = NULL;
char *fullpath = talloc_strdup(tmp, "");
struct dirent *e;
int n = 0;
while ((e = readdir(dir))) {
@ -1041,8 +1041,6 @@ static int script_readdir(lua_State *L, void *tmp)
lua_pushstring(L, name); // list index name
lua_settable(L, -3); // list
}
closedir(dir);
talloc_free(fullpath);
return 1;
}