summaryrefslogtreecommitdiff
path: root/src/fe-text
diff options
context:
space:
mode:
Diffstat (limited to 'src/fe-text')
-rw-r--r--src/fe-text/textbuffer.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/fe-text/textbuffer.c b/src/fe-text/textbuffer.c
index 3c11aea3..105e192a 100644
--- a/src/fe-text/textbuffer.c
+++ b/src/fe-text/textbuffer.c
@@ -151,7 +151,8 @@ static void text_chunk_append(TEXT_BUFFER_REC *buffer,
chunk = buffer->cur_text;
while (chunk->pos + len >= TEXT_CHUNK_USABLE_SIZE) {
left = TEXT_CHUNK_USABLE_SIZE - chunk->pos;
- if (data[left-1] == 0) left--; /* don't split the commands */
+ if (left > 0 && data[left-1] == 0)
+ left--; /* don't split the commands */
memcpy(chunk->buffer + chunk->pos, data, left);
chunk->pos += left;