From f2cc8d9640fa89205c4b576c3822034aa51a9f35 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 3 Oct 2001 21:24:52 +0000 Subject: [PATCH] fix a seg when the buffer wraps --- libs/console/buffer.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libs/console/buffer.c b/libs/console/buffer.c index a1192a2a3..a11ef54c4 100644 --- a/libs/console/buffer.c +++ b/libs/console/buffer.c @@ -98,6 +98,15 @@ Con_BufferAddText (con_buffer_t *buf, const char *text) if (pos - buf->buffer >= buf->buffer_size) pos = buf->buffer; cur_line->len++; + if (pos == tail_line->text) { + if (buf->num_lines > 0) + buf->num_lines--; + tail_line->text = 0; + tail_line->len = 0; + tail_line++; + if (tail_line - buf->lines >= buf->max_lines) + tail_line = buf->lines; + } if (c == '\n') { if (buf->num_lines < buf->max_lines) buf->num_lines++; @@ -108,15 +117,6 @@ Con_BufferAddText (con_buffer_t *buf, const char *text) cur_line->text = pos; cur_line->len = 0; } - if (pos == tail_line->text) { - if (buf->num_lines > 0) - buf->num_lines--; - tail_line->text = 0; - tail_line->len = 0; - tail_line++; - if (tail_line - buf->lines >= buf->max_lines) - tail_line = buf->lines; - } } buf->cur_line %= buf->max_lines; }