forked from osmocom/wireshark
Protect The tree and The tvb from being used outside their scope
svn path=/trunk/; revision=17307
This commit is contained in:
parent
2d7b55d808
commit
0646b11758
|
@ -38,6 +38,11 @@ static GPtrArray* outstanding_stuff = NULL;
|
|||
#define PUSH_PROTOITEM(L,i) g_ptr_array_add(outstanding_stuff,pushProtoItem(L,i))
|
||||
#define PUSH_PROTOTREE(L,t) g_ptr_array_add(outstanding_stuff,pushProtoTree(L,t))
|
||||
|
||||
void push_ProtoTree(lua_State*L, ProtoTree t) {
|
||||
void** p = (void**)pushProtoTree(L,t);
|
||||
g_ptr_array_add(outstanding_stuff,p);
|
||||
}
|
||||
|
||||
void clear_outstanding_trees(void) {
|
||||
while (outstanding_stuff->len) {
|
||||
void** p = (void**)g_ptr_array_remove_index_fast(outstanding_stuff,0);
|
||||
|
|
|
@ -302,6 +302,11 @@ void clear_outstanding_tvbs(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void push_Tvb(lua_State* L, Tvb tvb) {
|
||||
void** p = (void**)pushTvb(L,tvb);
|
||||
g_ptr_array_add(outstanding_stuff,p);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -154,9 +154,9 @@ void dissect_lua(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree) {
|
|||
|
||||
if (lua_isfunction(L,1)) {
|
||||
|
||||
pushTvb(L,tvb);
|
||||
push_Tvb(L,tvb);
|
||||
push_Pinfo(L,pinfo);
|
||||
pushProtoTree(L,tree);
|
||||
push_ProtoTree(L,tree);
|
||||
|
||||
if ( lua_pcall(L,3,0,0) ) {
|
||||
const gchar* error = lua_tostring(L,-1);
|
||||
|
@ -173,6 +173,8 @@ void dissect_lua(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree) {
|
|||
|
||||
clear_outstanding_tvbs();
|
||||
clear_outstanding_pinfos();
|
||||
clear_outstanding_trees();
|
||||
|
||||
|
||||
lua_pinfo = NULL;
|
||||
lua_tree = NULL;
|
||||
|
|
|
@ -255,9 +255,14 @@ extern void proto_register_lua(void);
|
|||
extern GString* lua_register_all_taps(void);
|
||||
extern void lua_prime_all_fields(proto_tree* tree);
|
||||
extern void lua_register_subtrees(void);
|
||||
|
||||
extern void push_Tvb(lua_State* L, Tvb tvb);
|
||||
extern void clear_outstanding_tvbs(void);
|
||||
|
||||
extern void push_Pinfo(lua_State* L, Pinfo p);
|
||||
extern void clear_outstanding_pinfos(void);
|
||||
|
||||
extern void push_ProtoTree(lua_State* L, ProtoTree t);
|
||||
extern void clear_outstanding_trees(void);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue