Skip to content

Commit

Permalink
Fix a bug that pgroonga.match_positions_byte() may return wrong location
Browse files Browse the repository at this point in the history
It's caused when 17 or more keywords are included in text.
  • Loading branch information
kou committed May 21, 2016
1 parent 5c97cdd commit 8da5020
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/pgrn_match_positions_byte.c
Expand Up @@ -47,6 +47,7 @@ PGrnMatchPositionsByte(text *target)
{
const char *string;
size_t stringLength;
int baseOffset = 0;

string = VARDATA_ANY(target);
stringLength = VARSIZE_ANY_EXHDR(target);
Expand All @@ -62,11 +63,12 @@ PGrnMatchPositionsByte(text *target)
string, stringLength,
hits, MAX_N_HITS, &rest);
for (i = 0; i < nHits; i++) {
GRN_UINT32_PUT(ctx, &buffer, hits[i].offset);
GRN_UINT32_PUT(ctx, &buffer, hits[i].offset + baseOffset);
GRN_UINT32_PUT(ctx, &buffer, hits[i].length);
}

chunkLength = rest - string;
baseOffset += chunkLength;
stringLength -= chunkLength;
string = rest;
#undef MAX_N_HITS
Expand Down

0 comments on commit 8da5020

Please sign in to comment.