forked from osmocom/wireshark
wslua: fix nstime memory leak after passing unknown encoding to TvbRange_nstime()
Move checking of encoding before allocating nstime. Found by clang. Change-Id: I3c1de5fae6fcf52393cc38302359f21f17808087 Reviewed-on: https://code.wireshark.org/review/25442 Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
cde023c3c5
commit
d672ee9372
|
@ -883,6 +883,11 @@ WSLUA_METHOD TvbRange_nstime(lua_State* L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (encoding & ~ENC_STR_TIME_MASK) {
|
||||
WSLUA_OPTARG_ERROR(TvbRange_nstime, ENCODING, "invalid encoding value");
|
||||
return 0;
|
||||
}
|
||||
|
||||
nstime = g_new(nstime_t,1);
|
||||
|
||||
if (encoding == 0) {
|
||||
|
@ -900,9 +905,6 @@ WSLUA_METHOD TvbRange_nstime(lua_State* L) {
|
|||
pushNSTime(L, nstime);
|
||||
lua_pushinteger(L, tvbr->len);
|
||||
}
|
||||
else if (encoding & ~ENC_STR_TIME_MASK) {
|
||||
WSLUA_OPTARG_ERROR(TvbRange_nstime, ENCODING, "invalid encoding value");
|
||||
}
|
||||
else {
|
||||
gint endoff = 0;
|
||||
nstime_t *retval = tvb_get_string_time(tvbr->tvb->ws_tvb, tvbr->offset, tvbr->len,
|
||||
|
|
Loading…
Reference in New Issue