wslua: avoid memleak on duplicate names for Proto.new

luaL_error never returns, free memory before.

Change-Id: Ibcdbdb6afea5d2dab7be6a16c4c2536dcf14220a
Reviewed-on: https://code.wireshark.org/review/14734
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Peter Wu 2016-03-31 21:52:11 +02:00 committed by Michael Mann
parent a5b8439453
commit 2ee62c55e7
1 changed files with 2 additions and 2 deletions

View File

@ -112,8 +112,8 @@ WSLUA_CONSTRUCTOR Proto_new(lua_State* L) {
loname = g_ascii_strdown(name, -1);
if (proto_check_field_name(loname)) {
WSLUA_ARG_ERROR(Proto_new,NAME,"invalid character in name");
g_free(loname);
WSLUA_ARG_ERROR(Proto_new,NAME,"invalid character in name");
return 0;
}
@ -121,9 +121,9 @@ WSLUA_CONSTRUCTOR Proto_new(lua_State* L) {
if ((proto_get_id_by_short_name(hiname) != -1) ||
(proto_get_id_by_filter_name(loname) != -1))
{
WSLUA_ARG_ERROR(Proto_new,NAME,"there cannot be two protocols with the same name");
g_free(loname);
g_free(hiname);
WSLUA_ARG_ERROR(Proto_new,NAME,"there cannot be two protocols with the same name");
return 0;
}