aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2023-12-08 09:48:08 +1100
committerNeil <nyamatongwe@gmail.com>2023-12-08 09:48:08 +1100
commit61e7372258a5446bfdfe00f8f1006f99b859716a (patch)
tree6db561369a856aaddc3579bfd4af33a5058d2956
parent735b490e3e29c6ee2cce6a723f900a5394e38399 (diff)
downloadscintilla-mirror-61e7372258a5446bfdfe00f8f1006f99b859716a.tar.gz
Throw error when allocating more than 2G without SC_DOCUMENTOPTION_TEXT_LARGE.
-rw-r--r--doc/ScintillaHistory.html4
-rw-r--r--src/CellBuffer.cxx4
2 files changed, 8 insertions, 0 deletions
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 "\&lt;" followed by search for "\&gt;".
<a href="https://sourceforge.net/p/scintilla/bugs/2413/">Bug #2413</a>.
</li>
+ <li>
+ 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.
+ </li>
</ul>
<h3>
<a href="https://www.scintilla.org/scintilla540.zip">Release 5.4.0</a>
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 <cstring>
#include <cstdio>
#include <cstdarg>
+#include <climits>
#include <stdexcept>
#include <string>
@@ -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);