aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wslua
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2019-10-28 09:52:12 +0100
committerRoland Knall <rknall@gmail.com>2019-10-28 15:05:54 +0000
commit551745998ef4a9352bca2a0035780bc1a96e55eb (patch)
tree8476113202bfff9b4fd37038bb1c6a3173295cd2 /epan/wslua
parent5fb897077e77c43d0080618d338443a8d62e5663 (diff)
wslua: Fix memleak of unregistered ProtoField strings
If a ProtoField object was created, but not linked to a Proto, then the strings field and all elements (depending on type) would leak. This is a follow-up to g79fef2ae and fixes the real issue in g44870fb1. Change-Id: I01880a92bb20fae45f68c754b07daeb07630deec Reviewed-on: https://code.wireshark.org/review/34872 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Vasil Velichkov <vvvelichkov@gmail.com> Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'epan/wslua')
-rw-r--r--epan/wslua/wslua_proto.c1
-rw-r--r--epan/wslua/wslua_proto_field.c3
2 files changed, 3 insertions, 1 deletions
diff --git a/epan/wslua/wslua_proto.c b/epan/wslua/wslua_proto.c
index 6ecc3de341..48ff4c6bda 100644
--- a/epan/wslua/wslua_proto.c
+++ b/epan/wslua/wslua_proto.c
@@ -638,6 +638,7 @@ int wslua_deregister_protocols(lua_State* L) {
/* Memory ownership was previously transferred to epan in Proto_commit */
f->name = NULL;
f->abbrev = NULL;
+ f->vs = NULL;
f->blob = NULL;
f->hfid = -2; /* Deregister ProtoField, freed in ProtoField__gc */
diff --git a/epan/wslua/wslua_proto_field.c b/epan/wslua/wslua_proto_field.c
index c050cdefbc..0a8394704f 100644
--- a/epan/wslua/wslua_proto_field.c
+++ b/epan/wslua/wslua_proto_field.c
@@ -1462,10 +1462,11 @@ static int ProtoField__gc(lua_State* L) {
return 0;
}
- /* Note: name, abbrev and blob will be NULL after Proto deregistration. */
+ /* Note: name, abbrev, blob and vs will be NULL after Proto deregistration. */
g_free(f->name);
g_free(f->abbrev);
g_free(f->blob);
+ proto_free_field_strings(f->type, f->base, f->vs);
g_free(f);
return 0;