From 9ce6af13789d36a43b4f3170969902d7f2c4f2cc Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 30 Apr 2020 12:46:51 +0100 Subject: [Minor] Lua_text: Add cookie for metatable --- src/lua/lua_text.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/lua/lua_text.c') diff --git a/src/lua/lua_text.c b/src/lua/lua_text.c index d0cc63134..e23eed8cb 100644 --- a/src/lua/lua_text.c +++ b/src/lua/lua_text.c @@ -1200,10 +1200,16 @@ lua_text_oneline (lua_State *L) return 1; } +/* Used to distinguish lua text metatable */ +static const guint rspamd_lua_text_cookie = 0x2b21ef6fU; + static gint lua_load_text (lua_State * L) { lua_newtable (L); + lua_pushstring (L, "cookie"); + lua_pushnumber (L, rspamd_lua_text_cookie); + lua_settable (L, -3); luaL_register (L, NULL, textlib_f); return 1; @@ -1213,6 +1219,9 @@ void luaopen_text (lua_State *L) { rspamd_lua_new_class (L, "rspamd{text}", textlib_m); + lua_pushstring (L, "cookie"); + lua_pushnumber (L, rspamd_lua_text_cookie); + lua_settable (L, -3); lua_pop (L, 1); rspamd_lua_add_preload (L, "rspamd_text", lua_load_text); -- cgit v1.2.3