From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=59099 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P1MQB-0002xM-Vx for qemu-devel@nongnu.org; Thu, 30 Sep 2010 12:55:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P1MQA-0000Bm-Mm for qemu-devel@nongnu.org; Thu, 30 Sep 2010 12:55:51 -0400 Received: from moutng.kundenserver.de ([212.227.126.171]:58350) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P1MQA-0000Bb-9u for qemu-devel@nongnu.org; Thu, 30 Sep 2010 12:55:50 -0400 Message-ID: <4CA4C0FF.90304@mail.berlios.de> Date: Thu, 30 Sep 2010 18:55:27 +0200 From: Stefan Weil MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] console: Avoid dereferencing NULL active_console References: <1284988279-8900-1-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1284988279-8900-1-git-send-email-stefanha@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Anthony Liguori , qemu-devel@nongnu.org, Michal Suchanek , Gerd Hoffmann Am 20.09.2010 15:11, schrieb Stefan Hajnoczi: > The console_select() function does not check that active_console is > non-NULL before dereferencing it. When invoked with qemu -nodefaults it > is possible to hit this case. > > This patch checks that active_console is non-NULL before stashing away > the old console dimensions in console_select(). > > Signed-off-by: Stefan Hajnoczi > --- > console.c | 6 ++++-- > 1 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/console.c b/console.c > index 698bc10..c1728b1 100644 > --- a/console.c > +++ b/console.c > @@ -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; To avoid that still more people fix the same bug, I'd appreciate shorter commit times for simple patches like this one. Cheers, Stefan Acked-by: Stefan Weil