path: root/epan
diff options
authorGuy Harris <guy@alum.mit.edu>2015-12-13 15:37:18 -0800
committerGuy Harris <guy@alum.mit.edu>2015-12-14 00:13:11 +0000
commit3d0f9a4397125af15f40ab29e3fd1ad0ae2aae1a (patch)
tree96668d305acf2e208312f79bdacfffca9e3791c7 /epan
parent41310fcaeead6a65401788c30abfde1e6464638a (diff)
No need to free the value of a string preference in the garbage collector.
The preference has already been deregistered at that point, so the value of the preference has been freed and the pointer to it has been set to null, so it's already been freed and its pointer no longer points to it and the free from Lua will do nothing. Change-Id: I11bf74932303151483cd3699659f67d64b466759 Reviewed-on: https://code.wireshark.org/review/12606 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan')
1 files changed, 10 insertions, 3 deletions
diff --git a/epan/wslua/wslua_pref.c b/epan/wslua/wslua_pref.c
index b154a27a69..e054546907 100644
--- a/epan/wslua/wslua_pref.c
+++ b/epan/wslua/wslua_pref.c
@@ -237,12 +237,19 @@ static range_t* get_range(lua_State *L, int idx_r, int idx_m)
static int Pref__gc(lua_State* L) {
Pref pref = toPref(L,1);
+ /*
+ * Only free unregistered and deregistered Pref; those have
+ * a null name pointer.
+ *
+ * They've been deregistered by wslua_deregister_protocols(),
+ * which means that prefs_deregister_protocol() has been called
+ * on them, which means that if their value is something that's
+ * allocated, it's been freed, and we don't have to do that
+ * ourselves.
+ */
if (! pref->name) {
- /* Only free unregistered and deregistered Pref */
- if (pref->type == PREF_STRING)
- g_free((void*)pref->value.s);