From 5e32b693f34e7432eb2fb86ebfd405cd19e77040 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Wed, 29 Nov 2023 11:02:23 +0100 Subject: [PATCH] fix: Crash when trying to analyze small files --- plugins/builtin/include/content/helpers/diagrams.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/builtin/include/content/helpers/diagrams.hpp b/plugins/builtin/include/content/helpers/diagrams.hpp index acaa5bd9e..1396ac1fc 100644 --- a/plugins/builtin/include/content/helpers/diagrams.hpp +++ b/plugins/builtin/include/content/helpers/diagrams.hpp @@ -154,7 +154,7 @@ namespace hex { void update(u8 byte) { // Check if there is some space left if (this->m_byteCount < this->m_fileSize) { - if ((this->m_byteCount % (this->m_fileSize / this->m_sampleSize)) == 0) + if ((this->m_byteCount % u64(std::ceil(double(this->m_fileSize) / double(this->m_sampleSize)))) == 0) this->m_buffer.push_back(byte); ++this->m_byteCount; if (this->m_byteCount == this->m_fileSize) { @@ -250,7 +250,7 @@ namespace hex { void update(u8 byte) { // Check if there is some space left if (this->m_byteCount < this->m_fileSize) { - if ((this->m_byteCount % (this->m_fileSize / this->m_sampleSize)) == 0) + if ((this->m_byteCount % u64(std::ceil(double(this->m_fileSize) / double(this->m_sampleSize)))) == 0) this->m_buffer.push_back(byte); ++this->m_byteCount; if (this->m_byteCount == this->m_fileSize) {