account for null terminator in repetition filter

This commit is contained in:
Akash Mozumdar 2019-06-13 04:08:40 -04:00
parent 76804dd0aa
commit 140c9057ea

View File

@ -313,7 +313,7 @@ namespace Util
{
wchar_t* end = text.data() + text.size();
for (int length = text.size() / 3; length > 6; --length)
if (wcsncmp(end - length * 3, end - length * 2, length) == 0 && wcsncmp(end - length * 3, end - length * 1, length) == 0)
if (memcmp(end - length * 3, end - length * 2, length * sizeof(wchar_t)) == 0 && memcmp(end - length * 3, end - length * 1, length * sizeof(wchar_t)) == 0)
return RemoveRepetition(text = std::wstring(end - length, length)), true;
return false;
}