From 15e78de432f55f5478f1b3994f3d7e060b60508d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Fri, 31 Oct 2014 13:21:46 +0100 Subject: Lua: Register dissectors only once. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I883e8560e9d101d34760d09715255e4fccc9eb98 Reviewed-on: https://code.wireshark.org/review/5022 Reviewed-by: Hadriel Kaplan Reviewed-by: Stig Bjørlykke Tested-by: Stig Bjørlykke --- epan/wslua/wslua_proto.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'epan/wslua/wslua_proto.c') diff --git a/epan/wslua/wslua_proto.c b/epan/wslua/wslua_proto.c index 382fe07862..f53135a7d0 100644 --- a/epan/wslua/wslua_proto.c +++ b/epan/wslua/wslua_proto.c @@ -1537,6 +1537,7 @@ WSLUA_CONSTRUCTOR Proto_new(lua_State* L) { hiname = g_ascii_strup(name, -1); proto->name = hiname; + proto->loname = loname; proto->desc = g_strdup(desc); proto->hfid = proto_register_protocol(proto->desc,hiname,loname); proto->ett = -1; @@ -1600,7 +1601,7 @@ WSLUA_FUNCTION wslua_register_postdissector(lua_State* L) { if(!proto->is_postdissector) { if (! proto->handle) { - proto->handle = new_create_dissector_handle(dissect_lua, proto->hfid); + proto->handle = new_register_dissector(proto->loname, dissect_lua, proto->hfid); } register_postdissector(proto->handle); @@ -1723,17 +1724,13 @@ static int Proto_set_dissector(lua_State* L) { if (lua_isfunction(L,2)) { /* insert the dissector into the dissectors table */ - gchar* loname = g_ascii_strdown(proto->name, -1); - lua_rawgeti(L, LUA_REGISTRYINDEX, lua_dissectors_table_ref); lua_replace(L, 1); lua_pushstring(L,proto->name); lua_insert(L, 2); /* function is now at 3 */ lua_settable(L,1); - proto->handle = new_create_dissector_handle(dissect_lua, proto->hfid); - - new_register_dissector(loname, dissect_lua, proto->hfid); + proto->handle = new_register_dissector(proto->loname, dissect_lua, proto->hfid); } else { luaL_argerror(L,2,"The dissector of a protocol must be a function"); } -- cgit v1.2.1