console: fix bug in console resizing
When resizing the scroll buffer to a bigger size we try to get lines from the scroll-back buffer into our current buffer. However, we do not know how many lines we can get so we start filling the bottom of the buffer and when no more lines are available, we simply move these lines to the top of the buffer. However, we didn't clear the bottom of the buffer after that operation so if the scroll-back buffer is too small to get us enough lines for resizing, we currently have a corrupted buffer-bottom. This fixes this bug by simply setting those lines to NULL as anyone would expect. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
0c7e50433a
commit
bff87253a8
@ -453,7 +453,7 @@ static int resize_scrollbuf(struct kmscon_buffer *buf, unsigned int y)
|
||||
if (!cache)
|
||||
return -ENOMEM;
|
||||
|
||||
memset(cache, 0, sizeof(struct line*) * y);
|
||||
memset(cache, 0, sizeof(struct line*) * siz);
|
||||
fill = y - buf->scroll_y;
|
||||
|
||||
for (i = 0; i < fill; ++i) {
|
||||
@ -465,6 +465,8 @@ static int resize_scrollbuf(struct kmscon_buffer *buf, unsigned int y)
|
||||
}
|
||||
buf->scroll_fill += i;
|
||||
memmove(cache, &cache[y - i], i * sizeof(struct line*));
|
||||
memset(&cache[i + buf->scroll_y], 0,
|
||||
(fill - i) * sizeof(struct line*));
|
||||
|
||||
if (buf->scroll_y)
|
||||
memcpy(&cache[i], buf->scroll_buf,
|
||||
|
Loading…
x
Reference in New Issue
Block a user