1
0
mirror of synced 2024-09-24 03:28:24 +02:00

fix: Infinite loop when doing forwards/backwards searches in some cases

Fixes #1734
This commit is contained in:
WerWolv 2024-06-07 21:00:55 +02:00
parent 08bb69c048
commit af59b9d2ca
2 changed files with 12 additions and 2 deletions

@ -1 +1 @@
Subproject commit 101da1689211a40c576b9d39d5cd38fa4c3d8c52
Subproject commit a34c241303d846b3a080920d7c6b1579522c163d

View File

@ -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) {