dfilter: fix memleaks with functions and slice operator
authorPeter Wu <peter@lekensteyn.nl>
Tue, 24 Apr 2018 20:34:26 +0000 (22:34 +0200)
committerAnders Broman <a.broman58@gmail.com>
Wed, 25 Apr 2018 06:57:00 +0000 (06:57 +0000)
commit614495138077a02a1fa09f6c59a0e6f1d783a1e4
tree83a4e289734d639109cec2e4ef7d1b49a4545e23
parent0de109ef57ebd6ddf25c87c599c9d8b522967a3b
dfilter: fix memleaks with functions and slice operator

Running tools/dfilter-test.py with LSan enabled resulted in 38 test
failures due to memory leaks from "fvalue_new". Problematic dfilters:
- Return values from functions, e.g. `len(data.data) > 8` (instruction
  CALL_FUNCTION invoking functions from epan/dfilter/dfunctions.c)
- Slice operator: `data.data[1:2] == aa:bb` (function mk_range)

These values end up in "registers", but as some values (from READ_TREE)
reference the proto tree, a new tracking flag ("owns_memory") is added.

Add missing tests for some functions and try to improve documentation.

Change-Id: I28e8cf872675d0a81ea7aa5fac7398257de3f47b
Reviewed-on: https://code.wireshark.org/review/27132
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
epan/dfilter/dfilter-int.h
epan/dfilter/dfilter.c
epan/dfilter/dfvm.c
tools/dftestlib/ipv4.py
tools/dftestlib/string_type.py
tshark.c