From 2449b08f64e60003a5d066438a735318e44bb642 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Thu, 6 Jul 2023 21:14:50 +0200 Subject: [PATCH] fix: Crash when trying to remove chunks larger than the whole file --- plugins/builtin/source/content/providers/file_provider.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/builtin/source/content/providers/file_provider.cpp b/plugins/builtin/source/content/providers/file_provider.cpp index 41f223ddf..8c02d39dc 100644 --- a/plugins/builtin/source/content/providers/file_provider.cpp +++ b/plugins/builtin/source/content/providers/file_provider.cpp @@ -115,6 +115,12 @@ namespace hex::plugin::builtin { } void FileProvider::remove(u64 offset, size_t size) { + if (offset > this->getActualSize() || size == 0) + return; + + if ((offset + size) > this->getActualSize()) + size = this->getActualSize() - offset; + auto oldSize = this->getActualSize(); std::vector buffer(0x1000);