From: Adam Dickmeiss Date: Mon, 8 Jun 2015 12:58:17 +0000 (+0200) Subject: CCL: fix leak on syntax errors with split-list X-Git-Tag: v5.14.0~1 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=6e8f854c8a6e4c4c8993bfd728367d1092a3108c;p=yaz-moved-to-github.git CCL: fix leak on syntax errors with split-list --- diff --git a/src/cclfind.c b/src/cclfind.c index 9403634..0ef140b 100644 --- a/src/cclfind.c +++ b/src/cclfind.c @@ -648,7 +648,10 @@ static struct ccl_rpn_node *split_recur(CCL_parser cclp, ccl_qualifier_t *qa, l > 1, /* auto_group */0); if (!p2) + { + ccl_rpn_delete(p_top); return 0; + } if (parent) { struct ccl_rpn_node *tmp = ccl_rpn_node_create(CCL_RPN_AND); @@ -660,6 +663,12 @@ static struct ccl_rpn_node *split_recur(CCL_parser cclp, ccl_qualifier_t *qa, p1 = split_recur(cclp, qa, p2, ar + l, sz - l); else p1 = p2; + if (!p1) + { + ccl_rpn_delete(p2); + ccl_rpn_delete(p_top); + return 0; + } p_top = ccl_rpn_node_mkbool(p_top, p1, CCL_RPN_OR); } assert(p_top); diff --git a/test/test_ccl.c b/test/test_ccl.c index 2cfc545..5fdb954 100644 --- a/test/test_ccl.c +++ b/test/test_ccl.c @@ -463,6 +463,9 @@ void tst1(int pass) "@or @attr 1=2 b @attr 1=3 b " "@or @attr 1=2 \"a b\" @attr 1=3 \"a b\" ")); + YAZ_CHECK(tst_ccl_query(bibset, "s2=a? b", 0)); + YAZ_CHECK(tst_ccl_query(bibset, "s2=a b?", 0)); + YAZ_CHECK(tst_ccl_query(bibset, "s2=a b? c", 0)); ccl_qual_rm(&bibset); }