diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2018-01-04 17:05:22 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2018-01-16 14:54:50 +0100 |
commit | b7438458a1f801096afe984e959855e77d22dc2e (patch) | |
tree | 2ad86805d31cf203462b81b8c189a7b4a3f06c13 | |
parent | 6b2fef739127ee6135d5ccc2da0bf1f3bebf66b7 (diff) | |
download | qemu-b7438458a1f801096afe984e959855e77d22dc2e.zip |
mips: fix potential fopen(NULL,...)
Spotted thanks to ASAN.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20180104160523.22995-18-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | hw/nvram/ds1225y.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/hw/nvram/ds1225y.c b/hw/nvram/ds1225y.c index 57d5ab2154..ad7345f288 100644 --- a/hw/nvram/ds1225y.c +++ b/hw/nvram/ds1225y.c @@ -80,7 +80,7 @@ static int nvram_post_load(void *opaque, int version_id) } /* Write back nvram contents */ - s->file = fopen(s->filename, "wb"); + s->file = s->filename ? fopen(s->filename, "wb") : NULL; if (s->file) { /* Write back contents, as 'wb' mode cleaned the file */ if (fwrite(s->contents, s->chip_size, 1, s->file) != 1) { @@ -126,7 +126,7 @@ static int nvram_sysbus_initfn(SysBusDevice *dev) sysbus_init_mmio(dev, &s->iomem); /* Read current file */ - file = fopen(s->filename, "rb"); + file = s->filename ? fopen(s->filename, "rb") : NULL; if (file) { /* Read nvram contents */ if (fread(s->contents, s->chip_size, 1, file) != 1) { |