diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2015-12-14 20:08:20 +0100 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-12-14 19:57:43 +0000 |
commit | 28207e5b82e7b667b2ea3bd15445b03e4fa7e6d5 (patch) | |
tree | 89c9cb408146ecbb016c3c6429923489f001dc62 /epan/wslua | |
parent | 56584b52e09ae806d85210c1f16f586db1c0d9bd (diff) |
Lua: Free Pref enum values
Free the Pref enum values in Pref__gc().
Change-Id: I4d66dbe7ee4879f3b14094135887d78cba876ea3
Reviewed-on: https://code.wireshark.org/review/12628
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/wslua')
-rw-r--r-- | epan/wslua/wslua_pref.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/epan/wslua/wslua_pref.c b/epan/wslua/wslua_pref.c index d9cf19b9d6..95e76cdd00 100644 --- a/epan/wslua/wslua_pref.c +++ b/epan/wslua/wslua_pref.c @@ -276,13 +276,30 @@ static int Pref__gc(lua_State* L) { if (! pref->name) { g_free(pref->label); g_free(pref->desc); - if (pref->type == PREF_STRING) { - /* - * Free the initial string value; if it's not NULL, that - * means this is a never-registered protocol, so the - * initial value hasn't been freed. - */ - g_free(pref->info.default_s); + switch (pref->type) { + case PREF_STRING: + /* + * Free the initial string value; if it's not NULL, that + * means this is a never-registered protocol, so the + * initial value hasn't been freed. + */ + g_free(pref->info.default_s); + break; + case PREF_ENUM: { + /* + * Free the enum values allocated in get_enum(). + */ + const enum_val_t *enum_valp = pref->info.enum_info.enumvals; + while (enum_valp->name) { + g_free((char *)enum_valp->name); + g_free((char *)enum_valp->description); + enum_valp++; + } + g_free ((enum_val_t *)pref->info.enum_info.enumvals); + break; + default: + break; + } } g_free(pref); } |