Skip to content

Commit

Permalink
fix: Infinite loop when doing forwards/backwards searches in some cases
Browse files Browse the repository at this point in the history
Fixes #1734
  • Loading branch information
WerWolv committed Jun 7, 2024
1 parent 08bb69c commit af59b9d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/external/libwolv
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,21 @@ namespace hex::plugin::builtin {
}

std::optional<Region> PopupFind::findByteSequence(const std::vector<u8> &sequence) const {
if (sequence.empty())
return std::nullopt;

auto provider = ImHexApi::Provider::get();
if (provider == nullptr)
return std::nullopt;

const auto providerSize = provider->getActualSize();
if (providerSize == 0x00)
return std::nullopt;

prv::ProviderReader reader(provider);

auto startAbsolutePosition = provider->getBaseAddress();
auto endAbsolutePosition = provider->getBaseAddress() + provider->getActualSize() - 1;
auto endAbsolutePosition = provider->getBaseAddress() + providerSize - 1;

constexpr static auto searchFunction = [](const auto &haystackBegin, const auto &haystackEnd,
const auto &needleBegin, const auto &needleEnd) {
Expand Down

0 comments on commit af59b9d

Please sign in to comment.