commit 9ce6af1: [Minor] Lua_text: Add cookie for metatable

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Apr 30 12:28:09 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-04-30 12:46:51 +0100
URL: https://github.com/rspamd/rspamd/commit/9ce6af13789d36a43b4f3170969902d7f2c4f2cc

[Minor] Lua_text: Add cookie for metatable

---
 src/lua/lua_text.c | 9 +++++++++
 1 file changed, 9 insertions(+)

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);


More information about the Commits mailing list