提交 ea6e4fe2 编写于 作者: T ths

Fix segfault when printing the help text, spotted by Stefan Weil.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3030 c046a42c-6fe2-441c-8c8c-71466251a162
上级 17508796
...@@ -6568,7 +6568,7 @@ int main_loop(void) ...@@ -6568,7 +6568,7 @@ int main_loop(void)
return ret; return ret;
} }
void help(void) static void help(const char *optarg)
{ {
printf("QEMU PC emulator version " QEMU_VERSION ", Copyright (c) 2003-2007 Fabrice Bellard\n" printf("QEMU PC emulator version " QEMU_VERSION ", Copyright (c) 2003-2007 Fabrice Bellard\n"
"usage: %s [options] [disk_image]\n" "usage: %s [options] [disk_image]\n"
...@@ -7450,12 +7450,12 @@ int main(int argc, char **argv) ...@@ -7450,12 +7450,12 @@ int main(int argc, char **argv)
break; break;
#endif #endif
case QEMU_OPTION_h: case QEMU_OPTION_h:
help(); help(optarg);
break; break;
case QEMU_OPTION_m: case QEMU_OPTION_m:
ram_size = atoi(optarg) * 1024 * 1024; ram_size = atoi(optarg) * 1024 * 1024;
if (ram_size <= 0) if (ram_size <= 0)
help(); help(optarg);
if (ram_size > PHYS_RAM_MAX_SIZE) { if (ram_size > PHYS_RAM_MAX_SIZE) {
fprintf(stderr, "qemu: at most %d MB RAM can be simulated\n", fprintf(stderr, "qemu: at most %d MB RAM can be simulated\n",
PHYS_RAM_MAX_SIZE / (1024 * 1024)); PHYS_RAM_MAX_SIZE / (1024 * 1024));
...@@ -7741,7 +7741,7 @@ int main(int argc, char **argv) ...@@ -7741,7 +7741,7 @@ int main(int argc, char **argv)
hd_filename[0] == '\0' && hd_filename[0] == '\0' &&
(cdrom_index >= 0 && hd_filename[cdrom_index] == '\0') && (cdrom_index >= 0 && hd_filename[cdrom_index] == '\0') &&
fd_filename[0] == '\0') fd_filename[0] == '\0')
help(); help("");
/* boot to floppy or the default cd if no hard disk defined yet */ /* boot to floppy or the default cd if no hard disk defined yet */
if (hd_filename[0] == '\0' && boot_device == 'c') { if (hd_filename[0] == '\0' && boot_device == 'c') {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册