From b6249fbd78a4baf646d21d539b7980b9c19dd2b5 Mon Sep 17 00:00:00 2001
From: nyamatongwe
+
@@ -396,6 +397,10 @@
href="#SCI_GETTEXTRANGE">SCI_GETTEXTRANGE,
SCI_ALLOCATE(int bytes, <unused>)
+ Allocate a document buffer large enough to store a given number of bytes.
+ The document will not be made smaller than its current contents.
SCI_ADDTEXT(int length, const char *s)
This inserts the first length characters from the string s
at the current position. This will include any 0's in the string that you might have expected
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx
index f6c1f7b17..27e62ac61 100644
--- a/src/CellBuffer.cxx
+++ b/src/CellBuffer.cxx
@@ -782,10 +782,10 @@ int CellBuffer::Length() {
}
void CellBuffer::Allocate(int newSize) {
- if (newSize > size) {
+ if (newSize > length) {
GapTo(length);
char *newBody = new char[newSize];
- memcpy(newBody, body, size);
+ memcpy(newBody, body, length);
delete []body;
body = newBody;
gaplen += newSize - size;
--
cgit v1.2.3