From 951a16f58a1372353a1c85ef9e162ddbe84bbff6 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 8 May 2007 14:49:38 +0000 Subject: [PATCH] Issue diagnostic for scan if 'set' in @attr 8=set does not exist. Fixed memory leak in rpn_scan (unreleased WRBUF for each term). --- index/rpnscan.c | 18 ++++++++++++++++-- test/api/t11.c | 24 +++++++++++++++++++++++- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/index/rpnscan.c b/index/rpnscan.c index 8ea6850..242ab45 100644 --- a/index/rpnscan.c +++ b/index/rpnscan.c @@ -1,4 +1,4 @@ -/* $Id: rpnscan.c,v 1.9 2007-05-08 12:50:04 adam Exp $ +/* $Id: rpnscan.c,v 1.10 2007-05-08 14:49:38 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -243,7 +243,11 @@ static ZEBRA_RES rpn_scan_ver2(ZebraHandle zh, ODR stream, NMEM nmem, if (trans_scan_term(zh, zapt, termz+prefix_len, index_type) == ZEBRA_FAIL) + { + for (i = 0; i < ord_no; i++) + wrbuf_destroy(ar[i].term); return ZEBRA_FAIL; + } wrbuf_rewind(ar[i].term); wrbuf_puts(ar[i].term, termz + prefix_len); ar[i].isam_p = 0; @@ -361,6 +365,9 @@ static ZEBRA_RES rpn_scan_ver2(ZebraHandle zh, ODR stream, NMEM nmem, *list = glist; + for (i = 0; i < ord_no; i++) + wrbuf_destroy(ar[i].term); + return ZEBRA_OK; } @@ -416,7 +423,6 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, if (termset_value_numeric != -2) { - sprintf(resname, "%d", termset_value_numeric); termset_name = resname; } @@ -424,6 +430,14 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, termset_name = termset_value_string; limit_set = resultSetRef (zh, termset_name); + + if (!limit_set) + { + zebra_setError(zh, + YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST, + termset_name); + return ZEBRA_FAIL; + } } } diff --git a/test/api/t11.c b/test/api/t11.c index c44a802..38dd43d 100644 --- a/test/api/t11.c +++ b/test/api/t11.c @@ -1,4 +1,4 @@ -/* $Id: t11.c,v 1.9 2007-01-15 15:10:20 adam Exp $ +/* $Id: t11.c,v 1.10 2007-05-08 14:49:38 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -48,6 +48,7 @@ static void tst(int argc, char **argv) ) */ +#if 0 if (1) { /* bad string use attrite, bug #647 */ @@ -145,6 +146,27 @@ static void tst(int argc, char **argv) const char *ent[] = { 0 }; YAZ_CHECK(tl_scan(zh, "@attr 1=4 z", -22, 10, -22, 0, 1, ent)); } + +#endif + + if (1) + { + const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 }; + + YAZ_CHECK(tl_query(zh, "@attr 1=4 c", 1)); + + /* must fail, because x is not a result set */ + YAZ_CHECK(tl_scan(zh, "@attr 8=x @attr 1=4 a", 1, 3, 0, 0, 0, 0)); + +#if 0 + /* bug 1114 */ + YAZ_CHECK(tl_scan(zh, "@attr 8=rsetname @attr 1=4 0", + 1, 20, 1, 6, 1, ent)); +#endif + + } + + YAZ_CHECK(tl_close_down(zh, zs)); } -- 1.7.10.4