summaryrefslogtreecommitdiff
path: root/src/fe-text/textbuffer.c
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-07-29 01:14:25 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-07-29 01:14:25 +0000
commit6ec7e12967f89e36455ff985871d99f81bd8d01e (patch)
tree7bae2c4ecc20e16dcacbb330966e9bc742a80ebb /src/fe-text/textbuffer.c
parent802ee7564c4001f722eb2fde35e36627c9248cd7 (diff)
downloadirssi-6ec7e12967f89e36455ff985871d99f81bd8d01e.zip
Added a small sanity check - the condition should never happen, but it seems
to have happened with one guy.. perhaps something else had corrupted memory. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1665 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-text/textbuffer.c')
-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;