From 61e7372258a5446bfdfe00f8f1006f99b859716a Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 8 Dec 2023 09:48:08 +1100 Subject: Throw error when allocating more than 2G without SC_DOCUMENTOPTION_TEXT_LARGE. --- doc/ScintillaHistory.html | 4 ++++ src/CellBuffer.cxx | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index ed14dd626..38cd4e3fa 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -613,6 +613,10 @@ Fix regular expression search failure when search for "\<" followed by search for "\>". Bug #2413. +
  • + With a document that does not have the SC_DOCUMENTOPTION_TEXT_LARGE option set, + allocating more than 2G (calling SCI_ALLOCATE or similar) will now fail with SC_STATUS_FAILURE. +
  • Release 5.4.0 diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx index 3c11939f4..32cc9d730 100644 --- a/src/CellBuffer.cxx +++ b/src/CellBuffer.cxx @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -773,6 +774,9 @@ Sci::Position CellBuffer::Length() const noexcept { } void CellBuffer::Allocate(Sci::Position newSize) { + if (!largeDocument && (newSize > INT32_MAX)) { + throw std::runtime_error("CellBuffer::Allocate: size of standard document limited to 2G."); + } substance.ReAllocate(newSize); if (hasStyles) { style.ReAllocate(newSize); -- cgit v1.2.3