aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2019-07-04 16:43:13 +0100
committerPeter Maydell <peter.maydell@linaro.org>2019-07-04 16:43:13 +0100
commitc3e1d838cfa5aac1a6210c8ddf182d0ef7d95dd8 (patch)
treeb2d942e8b4d8ffb0345a3eee5f675ba211fa9d12
parent234e256511e588680300600ce087c5185d68cf2a (diff)
parent5b8541c6c70db776d0701bb5ce5862ae15779fb5 (diff)
Merge remote-tracking branch 'remotes/kraxel/tags/ui-20190704-pull-request' into staging
ui: terminal emulation fix. # gpg: Signature made Thu 04 Jul 2019 08:04:31 BST # gpg: using RSA key 4CB6D8EED3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full] # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" [full] # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full] # Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138 * remotes/kraxel/tags/ui-20190704-pull-request: console: fix cell overflow Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--ui/console.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ui/console.c b/ui/console.c
index eb7e7e0c51..82d1ddac9c 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -484,7 +484,7 @@ static void text_console_resize(QemuConsole *s)
if (s->width < w1)
w1 = s->width;
- cells = g_new(TextCell, s->width * s->total_height);
+ cells = g_new(TextCell, s->width * s->total_height + 1);
for(y = 0; y < s->total_height; y++) {
c = &cells[y * s->width];
if (w1 > 0) {
@@ -541,6 +541,9 @@ static void update_xy(QemuConsole *s, int x, int y)
y2 += s->total_height;
}
if (y2 < s->height) {
+ if (x >= s->width) {
+ x = s->width - 1;
+ }
c = &s->cells[y1 * s->width + x];
vga_putcharxy(s, x, y2, c->ch,
&(c->t_attrib));
@@ -787,6 +790,9 @@ static void console_handle_escape(QemuConsole *s)
static void console_clear_xy(QemuConsole *s, int x, int y)
{
int y1 = (s->y_base + y) % s->total_height;
+ if (x >= s->width) {
+ x = s->width - 1;
+ }
TextCell *c = &s->cells[y1 * s->width + x];
c->ch = ' ';
c->t_attrib = s->t_attrib_default;
@@ -992,7 +998,7 @@ static void console_putchar(QemuConsole *s, int ch)
break;
case 1:
/* clear from beginning of line */
- for (x = 0; x <= s->x; x++) {
+ for (x = 0; x <= s->x && x < s->width; x++) {
console_clear_xy(s, x, s->y);
}
break;