]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-lua: dlua-dovecot - Ref event on push
authorAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 10 May 2021 16:46:53 +0000 (19:46 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 12 May 2021 09:06:46 +0000 (09:06 +0000)
Matches with unref on __gc.

src/auth/db-lua.c
src/lib-lua/dlua-dovecot.c

index 0ede7f7210f68033db16af5b77810e900f79bbba..d2b48e454e871d29641e9b10c51e92609332e5db 100644 (file)
@@ -228,6 +228,7 @@ static int auth_request_lua_event(lua_State *L)
        struct event *event = event_create(authdb_event(request));
 
        dlua_push_event(L, event);
+       event_unref(&event);
        return 1;
 }
 
index 8531e6eab72ef3eb3980741c174d1bb8b277bfbc..9dce09cfad70df15dc8e2c0bf38ca739ee8a206d 100644 (file)
@@ -270,6 +270,7 @@ void dlua_push_event(lua_State *L, struct event *event)
        /* we need to attach gc to userdata to support older lua*/
        struct event **ptr = lua_newuserdata(L, sizeof(struct event*));
        *ptr = event;
+       event_ref(event);
        lua_createtable(L, 0, 1);
        lua_pushcfunction(L, dlua_event_gc);
        lua_setfield(L, -2, "__gc");
@@ -471,6 +472,7 @@ static int dlua_event_new(lua_State *L)
        dlua_get_file_line(L, 1, &file, &line);
        event = event_create(parent, file, line);
        dlua_push_event(L, event);
+       event_unref(&event);
        return 1;
 }