Skip to content

Commit

Permalink
Merge pull request #77 from Siveya/5.0
Browse files Browse the repository at this point in the history
Fix the infinite loop when searching for something that cannot be found
  • Loading branch information
Dax89 authored Dec 25, 2023
2 parents c854dac + 805f492 commit 06136db
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion model/qhexutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,20 @@ qint64 findIter(qint64 startoffset, QHexFindDirection fd, const QHexView* hexvie

qint64 i = startoffset;

bool restartLoopOnce = true;

while(offset == -1 && (cfd == QHexFindDirection::Backward ? (i >= 0) : (i < hexdocument->length())))
{
if(!f(i, offset)) break;

if(cfd == QHexFindDirection::Backward) i--;
else i++;

if(fd == QHexFindDirection::All && i >= hexdocument->length()) i = 0;
if(fd == QHexFindDirection::All && i >= hexdocument->length() && restartLoopOnce)
{
i = 0;
restartLoopOnce = false;
}
}

return offset;
Expand Down

0 comments on commit 06136db

Please sign in to comment.