From: Adam Dickmeiss Date: Thu, 4 Mar 2010 10:25:59 +0000 (+0100) Subject: grs1: avoid term_len < 0 for .abs operator 'range' X-Git-Tag: v2.0.44~11^2~3 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=4815bf6068b5a2623c50475e0e5ec598709934e0;p=idzebra-moved-to-github.git grs1: avoid term_len < 0 for .abs operator 'range' A negative term_len could happen for Zebra in many releases but it only reveals itself in YAZ 4 where WRBUF uses size_t length. --- diff --git a/index/recgrs.c b/index/recgrs.c index a481e1d..500a0b1 100644 --- a/index/recgrs.c +++ b/index/recgrs.c @@ -104,12 +104,18 @@ static int sp_range(struct source_parser *sp, data1_node *n, RecWord *wrd) return 0; sp_lex(sp); - if (wrd->term_buf && wrd->term_len) + if (wrd->term_buf) { - wrd->term_buf += start; - wrd->term_len -= start; - if (wrd->term_len > len) - wrd->term_len = len; + if (start >= wrd->term_len) + wrd->term_len = 0; + else + { + wrd->term_len -= start; + wrd->term_buf += start; + + if (wrd->term_len > len) + wrd->term_len = len; + } } return 1; } @@ -563,7 +569,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n, memcpy(&wrd_tl, wrd, sizeof(*wrd)); if (tl->source) sp_parse(sp, n, &wrd_tl, tl->source); - + /* this is just the old fashioned attribute based index */ wrd_tl.index_name = tl->index_name; if (p->flagShowRecords)