Wireshark-commits: [Wireshark-commits] master e8e60df: dfilter: fix memory leaks if a dfilter fails
From: Wireshark code review <code-review-do-not-reply@xxxxxxxxxxxxx>
Date: Mon, 28 Jan 2019 11:09:23 +0000
URL: https://code.wireshark.org/review/gitweb?p=wireshark.git;a=commit;h=e8e60df4ce1aeed350c962c329c1eef4c09ce669
Submitter: "Peter Wu <peter@xxxxxxxxxxxxx>"
Changed: branch: master
Repository: wireshark

Commits:

e8e60df by Peter Wu (peter@xxxxxxxxxxxxx):

    dfilter: fix memory leaks if a dfilter fails to compile
    
    A display filter can contain values such as strings, numbers, etc. These
    are internally stored in a fvalue_t structure. While compiling a display
    filter, it will store a fvalue_t in a node of type STTYPE_FVALUE.
    
    These nodes are created while parsing the dfilter in dfilter_compile().
    If the semantic check and conversion (dfw_semcheck()) succeeds, it will
    transfer the values of the parsed tree to dfw_gencode(). After that,
    dfwork_free will dispose the tree while a compiled dfilter code remains.
    When the dfilter code is destroyed, it will free the values too.
    
    However, when dfw_semcheck() fails (for example, due to an illegal
    filter such as "len(badname)==1"), it will skip "dfw_gencode()" and
    consequently the fvalue data is not transferred nor freed. Fix this by
    always freeing the data (unless the data was stolen by dfw_gencode()).
    
    Fixes a memory leak reported for case_dfunction_string::test_fail_2
    which was detected by ASAN.
    
    Bug: 15442
    Change-Id: I9b1cb613659890c8ddcfa57f11f9d3f61a51a3f9
    Reviewed-on: https://code.wireshark.org/review/31757
    Petri-Dish: Peter Wu <peter@xxxxxxxxxxxxx>
    Tested-by: Petri Dish Buildbot
    Reviewed-by: Peter Wu <peter@xxxxxxxxxxxxx>
    

Actions performed:

    from  6a49c72   wslua: include Lua stack trace in startup error messages
     add  e8e60df   dfilter: fix memory leaks if a dfilter fails to compile


Summary of changes:
 epan/dfilter/gencode.c        |  2 +-
 epan/dfilter/sttype-pointer.c | 14 +++++++++++++-
 epan/dfilter/syntax-tree.c    | 10 ++++++++++
 epan/dfilter/syntax-tree.h    |  3 +++
 4 files changed, 27 insertions(+), 2 deletions(-)