]> git.ipfire.org Git - location/libloc.git/commitdiff
lua: Initialize the database object pointer
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 21 May 2024 15:34:57 +0000 (15:34 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 21 May 2024 15:34:57 +0000 (15:34 +0000)
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 <michael.tremer@ipfire.org>
src/lua/database.c

index fcbbad04567e340fa50794be49611fd92dcea284..8d10c43cbb18d6a62b321a2ad1fa2d729b2c9a09 100644 (file)
@@ -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");