From: Adam Dickmeiss Date: Wed, 10 Sep 2008 12:50:00 +0000 (+0200) Subject: Proper sort entry copying X-Git-Tag: v2.0.34~27 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=b81eb4e30e5febe06da7118cd9a84a63604cb1e0;p=idzebra-moved-to-github.git Proper sort entry copying --- diff --git a/index/zsets.c b/index/zsets.c index 5187cf4..225876c 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -581,18 +581,31 @@ void resultSetInsertSort(ZebraHandle zh, ZebraSet sset, int off = 0; while (off != wrbuf_len(w)) { + size_t l = strlen(wrbuf_buf(w)+off); assert(off < wrbuf_len(w)); + + if (l >= SORT_IDX_ENTRYSIZE) + l = SORT_IDX_ENTRYSIZE-1; if (off == 0) - strcpy(this_entry_buf, wrbuf_buf(w)); + { + memcpy(this_entry_buf, wrbuf_buf(w)+off, l); + this_entry_buf[l] = '\0'; + } else if (criteria[i].relation == 'A') { if (strcmp(wrbuf_buf(w)+off, this_entry_buf) < 0) - strcpy(this_entry_buf, wrbuf_buf(w)+off); + { + memcpy(this_entry_buf, wrbuf_buf(w)+off, l); + this_entry_buf[l] = '\0'; + } } else if (criteria[i].relation == 'D') { if (strcmp(wrbuf_buf(w)+off, this_entry_buf) > 0) - strcpy(this_entry_buf, wrbuf_buf(w)+off); + { + memcpy(this_entry_buf, wrbuf_buf(w)+off, l); + this_entry_buf[l] = '\0'; + } } off += 1 + strlen(wrbuf_buf(w)+off); }