Skip to content

Commit

Permalink
Fix rag analyzer (#2231)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

Fix memory issue of rage tokenizer

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
  • Loading branch information
yingfeng authored Nov 13, 2024
1 parent d990b18 commit 4d3d137
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/common/analyzer/rag_analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,8 @@ class NLTKWordTokenizer {
return text;
}

size_t outlength = text.length() * 1.5;
UniquePtr<PCRE2_UCHAR> buffer = MakeUnique<PCRE2_UCHAR>(outlength);
size_t outlength = text.length() * 2 < 1024 ? 1024 : text.length() * 2;
auto buffer = MakeUnique<PCRE2_UCHAR[]>(outlength);
pcre2_substitute(re,
pcre2_subject,
text.length(),
Expand All @@ -445,7 +445,6 @@ class NLTKWordTokenizer {
PCRE2_ZERO_TERMINATED,
buffer.get(),
&outlength);

pcre2_match_data_free(match_data);
pcre2_code_free(re);

Expand Down

0 comments on commit 4d3d137

Please sign in to comment.