Skip to content

Commit

Permalink
Add an extra check against infinite looping in searchReplaceAll
Browse files Browse the repository at this point in the history
  • Loading branch information
Coises committed Jan 4, 2024
1 parent d906974 commit 4164a07
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,7 @@ void ColumnsPlusPlusData::searchReplaceAll(bool partial, bool before) {
Scintilla::Position nullAt = -1;
for (Scintilla::Position cpFrom = partialStart, cpTo; cpFrom < partialEnd; cpFrom = cpTo) {
cpTo = sci.IndicatorEnd(searchData.indicator, cpFrom);
if (cpTo <= cpFrom) break; // Safety check against indefinite loop; in principle, this shouldn't happen.
if (sci.IndicatorValueAt(searchData.indicator, cpFrom)) {
Scintilla::Position start = sci.IndicatorStart(searchData.indicator, cpFrom);
rx.invalidate();
Expand Down Expand Up @@ -1045,6 +1046,7 @@ void ColumnsPlusPlusData::searchReplaceAll(bool partial, bool before) {
std::string sciFind = prepareFind(*this);
for (Scintilla::Position cpFrom = partialStart, cpTo; cpFrom < partialEnd; cpFrom = cpTo) {
cpTo = sci.IndicatorEnd(searchData.indicator, cpFrom);
if (cpTo <= cpFrom) break; // Safety check against indefinite loop; in principle, this shouldn't happen.
if (sci.IndicatorValueAt(searchData.indicator, cpFrom)) {
while (cpFrom < cpTo) {
sci.SetTargetRange(cpFrom, cpTo);
Expand Down

0 comments on commit 4164a07

Please sign in to comment.