From 7a30072fcb0e460c5871df3cb63154e45e90b2f6 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Fri, 13 Nov 2020 13:50:59 +0100 Subject: [PATCH] Removed useless pattern file size limitation --- include/views/view_pattern.hpp | 2 +- source/views/view_pattern.cpp | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/views/view_pattern.hpp b/include/views/view_pattern.hpp index d341e28fb..7594b3c96 100644 --- a/include/views/view_pattern.hpp +++ b/include/views/view_pattern.hpp @@ -26,7 +26,7 @@ namespace hex { void createView() override; private: - char *m_buffer; + char *m_buffer = nullptr; std::vector &m_highlights; prv::Provider* &m_dataProvider; diff --git a/source/views/view_pattern.cpp b/source/views/view_pattern.cpp index 73c4f0ccb..15fbcd5e7 100644 --- a/source/views/view_pattern.cpp +++ b/source/views/view_pattern.cpp @@ -7,11 +7,10 @@ namespace hex { ViewPattern::ViewPattern(prv::Provider* &dataProvider, std::vector &highlights) : View(), m_dataProvider(dataProvider), m_highlights(highlights) { - this->m_buffer = new char[0xFFFFFF]; - std::memset(this->m_buffer, 0x00, 0xFFFFFF); } ViewPattern::~ViewPattern() { - delete[] this->m_buffer; + if (this->m_buffer != nullptr) + delete[] this->m_buffer; } void ViewPattern::createMenu() { @@ -66,10 +65,10 @@ namespace hex { size_t size = ftell(file); rewind(file); - if (size > 0xFF'FFFF) { - fclose(file); - return; - } + if (this->m_buffer != nullptr) + delete[] this->m_buffer; + this->m_buffer = new char[size + 1]; + std::memset(this->m_buffer, 0x00, size + 1); fread(this->m_buffer, size, 1, file);