From: Michael Tremer Date: Tue, 21 May 2024 15:34:57 +0000 (+0000) Subject: lua: Initialize the database object pointer X-Git-Tag: 0.9.18~54 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=86b168ed95e468e8be4ba25dc7e65e7cf37b486a;p=location%2Flibloc.git lua: Initialize the database object pointer Unfortunately Lua does not initialize any new user data. Therefore it could happen that the cleanup function will try to tidy up after a new Database object could not be set up correctly and cause a segmentation fault. Signed-off-by: Michael Tremer --- diff --git a/src/lua/database.c b/src/lua/database.c index fcbbad0..8d10c43 100644 --- a/src/lua/database.c +++ b/src/lua/database.c @@ -52,6 +52,7 @@ static int Database_open(lua_State* L) { // Allocate a new object Database* self = (Database*)lua_newuserdata(L, sizeof(*self)); + self->db = NULL; // Set metatable luaL_setmetatable(L, "location.Database");