From 3e87022da15526f533dd768e0f43a2c8b34be37b Mon Sep 17 00:00:00 2001 From: WerWolv Date: Thu, 13 Apr 2023 16:12:00 +0200 Subject: [PATCH] fix: Provider undo stack not being handled correctly --- lib/libimhex/source/providers/provider.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/libimhex/source/providers/provider.cpp b/lib/libimhex/source/providers/provider.cpp index 1d038b58a..3b42221f5 100644 --- a/lib/libimhex/source/providers/provider.cpp +++ b/lib/libimhex/source/providers/provider.cpp @@ -197,8 +197,14 @@ namespace hex::prv { } void Provider::addPatch(u64 offset, const void *buffer, size_t size, bool createUndo) { - if (createUndo) + if (createUndo) { + // Delete all patches after the current one if a modification is made while + // the current patch list is not at the end of the undo stack + if (std::next(this->m_currPatches) != this->m_patches.end()) + this->m_patches.erase(std::next(this->m_currPatches), this->m_patches.end()); + createUndoPoint(); + } for (u64 i = 0; i < size; i++) { u8 patch = reinterpret_cast(buffer)[i];