提交 47dc0ec5 编写于 作者: P Peter Maydell

hw/sparc/leon3: Don't call get_image_size() on a NULL pointer

get_image_size() doesn't handle being passed a NULL pointer, so
avoid doing that. Spotted by the clang ub sanitizer (which notices
the attempt to pass NULL to open()).
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
Message-id: 1470391439-28427-1-git-send-email-peter.maydell@linaro.org
上级 f5edfcfa
...@@ -171,7 +171,11 @@ static void leon3_generic_hw_init(MachineState *machine) ...@@ -171,7 +171,11 @@ static void leon3_generic_hw_init(MachineState *machine)
} }
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
bios_size = get_image_size(filename); if (filename) {
bios_size = get_image_size(filename);
} else {
bios_size = -1;
}
if (bios_size > prom_size) { if (bios_size > prom_size) {
fprintf(stderr, "qemu: could not load prom '%s': file too big\n", fprintf(stderr, "qemu: could not load prom '%s': file too big\n",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册