aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>2009-02-09 19:02:09 +0000
committeraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>2009-02-09 19:02:09 +0000
commit491150db37429b2f962f7bf13a10776d81049c81 (patch)
tree1b8760721aa941ed6a7ca0bedc591499127ebe63
parent15abc4514ef2699cbbe1ab3c09ce72002ccb8215 (diff)
downloadqemu-491150db37429b2f962f7bf13a10776d81049c81.zip
qemu-491150db37429b2f962f7bf13a10776d81049c81.tar.gz
qemu-491150db37429b2f962f7bf13a10776d81049c81.tar.bz2
Fix crash caused by missing command line arguments
Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6580 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--linux-user/main.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/linux-user/main.c b/linux-user/main.c
index 95efe39..00259dc 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -2301,6 +2301,8 @@ int main(int argc, char **argv, char **envp)
if (envlist_unsetenv(envlist, r) != 0)
usage();
} else if (!strcmp(r, "s")) {
+ if (optind >= argc)
+ break;
r = argv[optind++];
x86_stack_size = strtol(r, (char **)&r, 0);
if (x86_stack_size <= 0)
@@ -2312,6 +2314,8 @@ int main(int argc, char **argv, char **envp)
} else if (!strcmp(r, "L")) {
interp_prefix = argv[optind++];
} else if (!strcmp(r, "p")) {
+ if (optind >= argc)
+ break;
qemu_host_page_size = atoi(argv[optind++]);
if (qemu_host_page_size == 0 ||
(qemu_host_page_size & (qemu_host_page_size - 1)) != 0) {
@@ -2319,12 +2323,14 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
} else if (!strcmp(r, "g")) {
+ if (optind >= argc)
+ break;
gdbstub_port = atoi(argv[optind++]);
} else if (!strcmp(r, "r")) {
qemu_uname_release = argv[optind++];
} else if (!strcmp(r, "cpu")) {
cpu_model = argv[optind++];
- if (strcmp(cpu_model, "?") == 0) {
+ if (cpu_model == NULL || strcmp(cpu_model, "?") == 0) {
/* XXX: implement xxx_cpu_list for targets that still miss it */
#if defined(cpu_list)
cpu_list(stdout, &fprintf);