aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wslua/wslua_proto.c
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2019-10-28 15:11:15 +0100
committerRoland Knall <rknall@gmail.com>2019-10-28 16:16:49 +0000
commit541afedfbc64503df0e7301d7614a30c9ba8ad49 (patch)
tree42721eefd7f8cc27619f1224289012f4b403b607 /epan/wslua/wslua_proto.c
parente8265fbfe3ff2b5bc7da4ef876bb4e084ac25332 (diff)
wslua: Fix memleak of unregistered ProtoExpert
If a ProtoExpert object was created, but not linked to a Proto, then the object and some fields (abbrev, text) would leak. This is a follow-up to g79fef2ae. Change-Id: Ic0b44e8b70895a19d9b52a0e44064a1e76a58fa0 Reviewed-on: https://code.wireshark.org/review/34876 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'epan/wslua/wslua_proto.c')
-rw-r--r--epan/wslua/wslua_proto.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/epan/wslua/wslua_proto.c b/epan/wslua/wslua_proto.c
index 48ff4c6bda..5ee8f905d5 100644
--- a/epan/wslua/wslua_proto.c
+++ b/epan/wslua/wslua_proto.c
@@ -649,6 +649,11 @@ int wslua_deregister_protocols(lua_State* L) {
lua_rawgeti(L, LUA_REGISTRYINDEX, proto->expert_info_table_ref);
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
ProtoExpert pe = checkProtoExpert(L,-1);
+
+ /* Memory ownership was previously transferred to epan in Proto_commit */
+ pe->abbrev = NULL;
+ pe->text = NULL;
+
pe->ids.hf = -2; /* Deregister ProtoExpert, freed in ProtoExpert__gc */
}
lua_pop(L, 1);
@@ -749,10 +754,11 @@ int Proto_commit(lua_State* L) {
eiri.eiinfo.severity = e->severity;
eiri.eiinfo.summary = e->text;
- if (e->ids.ei != EI_INIT_EI || e->ids.hf != EI_INIT_HF) {
+ if (e->ids.ei != EI_INIT_EI || e->ids.hf != -2) {
return luaL_error(L,"expert fields can be registered only once");
}
+ e->ids.hf = -1;
g_array_append_val(proto->eia,eiri);
}