Skip to contentSkip to conversation

console: Fix crash with missing active_console (null pointer access)

PATCH In review Stefan Weil 2 participants 2 messages Sep 29, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 console: Fix crash with missing active_console (null pointer access)

Console selection crashed qemu when there was no active console. Run "qemu -nodefaults" with SDL configured and press alt-ctrl-2 to reproduce this bug.

Check active_console before trying to get the dimensions of it (this was obviously the last location which did not do this check).

---
 console.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
console.c +4 -2
index 698bc10..c1728b1 100644
@@ -1060,8 +1060,10 @@ void console_select(unsigned int index)
 
     if (index >= MAX_CONSOLES)
         return;
-    active_console->g_width = ds_get_width(active_console->ds);
-    active_console->g_height = ds_get_height(active_console->ds);
+    if (active_console) {
+        active_console->g_width = ds_get_width(active_console->ds);
+        active_console->g_height = ds_get_height(active_console->ds);
+    }
     s = consoles[index];
     if (s) {
         DisplayState *ds = s->ds;
Signature · 1 line
1.7.1
#1 lore raw

Hi,

Am 29.09.2010 um 21:29 schrieb Stefan Weil:

Quoted 8 lines

Console selection crashed qemu when there was no active console. Run "qemu -nodefaults" with SDL configured and press alt-ctrl-2 to reproduce this bug.

Check active_console before trying to get the dimensions of it (this was obviously the last location which did not do this check).

Same patch has been submitted by Stefan Hajnoczi!

Andreas

Quoted 23 lines

---
console.c | 6 ++++--

1 files changed, 4 insertions(+), 2 deletions(-)
console.c +4 -2
index 698bc10..c1728b1 100644
@@ -1060,8 +1060,10 @@ void console_select(unsigned int index)
 
    if (index >= MAX_CONSOLES)
        return;
-    active_console->g_width = ds_get_width(active_console->ds);
-    active_console->g_height = ds_get_height(active_console->ds);
+    if (active_console) {
+        active_console->g_width = ds_get_width(active_console->ds);
+        active_console->g_height = ds_get_height(active_console->ds);
+    }
    s = consoles[index];
    if (s) {
        DisplayState *ds = s->ds;
Signature · 1 line
1.7.1