From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzMh9-0002RU-60 for qemu-devel@nongnu.org; Thu, 09 Aug 2012 02:58:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SzMh8-0007Rk-4p for qemu-devel@nongnu.org; Thu, 09 Aug 2012 02:58:11 -0400 From: riegamaths@gmail.com Date: Thu, 9 Aug 2012 14:57:51 +0800 Message-Id: <1344495471-3957-1-git-send-email-riegamaths@gmail.com> Subject: [Qemu-devel] [RESEND PATCH] vl.c: Exit QEMU early if no machine is found List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-trivial Cc: Anthony Liguori , qemu-devel , Dunrong Huang , Stefan Hajnoczi From: Dunrong Huang We check whether the variable machine is NULL or not before accessing it. If machine is NULL, exit QEMU with an error, this can avoids a segfault error. Signed-off-by: Dunrong Huang --- vl.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/vl.c b/vl.c index e71cb30..1596617 100644 --- a/vl.c +++ b/vl.c @@ -3204,6 +3204,11 @@ int main(int argc, char **argv, char **envp) } loc_set_none(); + if (machine == NULL) { + fprintf(stderr, "No machine found.\n"); + exit(1); + } + if (machine->hw_version) { qemu_set_version(machine->hw_version); } @@ -3246,11 +3251,6 @@ int main(int argc, char **argv, char **envp) data_dir = CONFIG_QEMU_DATADIR; } - if (machine == NULL) { - fprintf(stderr, "No machine found.\n"); - exit(1); - } - /* * Default to max_cpus = smp_cpus, in case the user doesn't * specify a max_cpus value. -- 1.7.8.6