[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] hw/sparc/leon3: Don't call get_image_size() on a NU
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PATCH] hw/sparc/leon3: Don't call get_image_size() on a NULL pointer |
Date: |
Fri, 5 Aug 2016 11:03:59 +0100 |
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: Peter Maydell <address@hidden>
---
hw/sparc/leon3.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c
index dbae41f..6e16478 100644
--- a/hw/sparc/leon3.c
+++ b/hw/sparc/leon3.c
@@ -171,7 +171,11 @@ static void leon3_generic_hw_init(MachineState *machine)
}
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) {
fprintf(stderr, "qemu: could not load prom '%s': file too big\n",
--
2.7.4
- [Qemu-devel] [PATCH] hw/sparc/leon3: Don't call get_image_size() on a NULL pointer,
Peter Maydell <=