From 86b168ed95e468e8be4ba25dc7e65e7cf37b486a Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 21 May 2024 15:34:57 +0000 Subject: [PATCH] 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 --- src/lua/database.c | 1 + 1 file changed, 1 insertion(+) 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"); -- 2.39.5