aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wslua
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss.ws@gmail.com>2016-10-06 10:26:27 -0400
committerPeter Wu <peter@lekensteyn.nl>2016-10-14 17:00:06 +0000
commit38682523f9ce3ed378c782a848ba1ba5a6fe430f (patch)
treea1a3d20c6f1103a7f44f8ae45f48adb0cacf1843 /epan/wslua
parent3a08906ca7c1e66037977f0e701af6a7c89bd4f9 (diff)
Lua: allow creating TVBs after calling other (Lua) dissectors.
Don't set `lua_tvb` (or any of the other global variables) to NULL after a Lua dissector is called: it's possible that the caller is also a Lua dissector which may want/need that (global) variable to still be set (to the value it had before the sub-dissector was called). This fixes the problem reported in: https://ask.wireshark.org/questions/56110/lua-error-tvbs-can-only-be-created-and-used-in-dissectors Making these variables not be a globals (as suggested at the top of init_wslua.c) might be a better solution--for another day. Change-Id: I14fb8ec35b62abeda3f3471a323b88c80537a06e Reviewed-on: https://code.wireshark.org/review/18095 Petri-Dish: Jeff Morriss <jeff.morriss.ws@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Tested-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'epan/wslua')
-rw-r--r--epan/wslua/init_wslua.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/epan/wslua/init_wslua.c b/epan/wslua/init_wslua.c
index 2415bffc7e..878b38ca55 100644
--- a/epan/wslua/init_wslua.c
+++ b/epan/wslua/init_wslua.c
@@ -167,6 +167,9 @@ int get_hf_wslua_text(void) {
int dissect_lua(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_) {
int consumed_bytes = tvb_captured_length(tvb);
+ tvbuff_t *saved_lua_tvb = lua_tvb;
+ packet_info *saved_lua_pinfo = lua_pinfo;
+ struct _wslua_treeitem *saved_lua_tree = lua_tree;
lua_pinfo = pinfo;
lua_tvb = tvb;
@@ -211,9 +214,9 @@ int dissect_lua(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data
wmem_register_callback(pinfo->pool, lua_pinfo_end, NULL);
- lua_pinfo = NULL;
- lua_tree = NULL;
- lua_tvb = NULL;
+ lua_pinfo = saved_lua_pinfo;
+ lua_tree = saved_lua_tree;
+ lua_tvb = saved_lua_tvb;
return consumed_bytes;
@@ -228,6 +231,9 @@ int dissect_lua(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data
*/
gboolean heur_dissect_lua(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_) {
gboolean result = FALSE;
+ tvbuff_t *saved_lua_tvb = lua_tvb;
+ packet_info *saved_lua_pinfo = lua_pinfo;
+ struct _wslua_treeitem *saved_lua_tree = lua_tree;
lua_tvb = tvb;
lua_pinfo = pinfo;
@@ -306,9 +312,9 @@ gboolean heur_dissect_lua(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, v
wmem_register_callback(pinfo->pool, lua_pinfo_end, NULL);
- lua_pinfo = NULL;
- lua_tree = NULL;
- lua_tvb = NULL;
+ lua_pinfo = saved_lua_pinfo;
+ lua_tree = saved_lua_tree;
+ lua_tvb = saved_lua_tvb;
return result;
}