Fix invalid empty interval in punct_stripped() for all-punctuation words #4404
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
punct_stripped() may currently produce invalid empty intervals (where end < start) for all-punctuation words. As a result, EqualIgnoringCaseAndTerminalPunct() crashes in this loop due to an unsigned integer underflow in w1end - w1start:
for (unsigned i = 0; i < w1end - w1start; i++) {
if (uchset->to_lower(word1.unichar_id(w1start + i)) !=
uchset->to_lower(word2.unichar_id(w2start + i))) {
return false;
}
}
Bug was introduced with the following commit:
Revision: 97048fe
Author: Stefan Weil sw@weilnetz.de
Date: 09/10/2021 20:50:39
Message:
ccstruct: Fix some signed/unsigned compiler warnings
Remove also a local buffer in function REJMAP::print.
There was no unsigned integer underflow before, because the interval was signed.