From 23730825fb3e14010e05c4ce29ee86e2342451ce Mon Sep 17 00:00:00 2001 From: Radoslaw Kujawa Date: Mon, 25 Jan 2021 01:00:18 +0100 Subject: [PATCH] Avoid null pointer dereference. --- src/bus.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bus.c b/src/bus.c index 04ee727..cd08906 100644 --- a/src/bus.c +++ b/src/bus.c @@ -118,7 +118,7 @@ bus_read_1(bus_t *t, uint16_t addr) bus_access_device(t, addr, &d, &off); if (d == NULL) - return 0xFF; + return 0xFF; /* simulate floting pins */ else val = d->read_1(d, off); @@ -139,6 +139,13 @@ bus_write_1(bus_t *t, uint16_t addr, uint8_t val) bus_access_device(t, addr, &d, &off); + if (d == NULL) { + if (t->access_debug) + rk65c02_log(LOG_DEBUG, "unmapped bus WRITE @ %x (off %x) value %x\n", + addr, off, val); + return; + } + if (t->access_debug) rk65c02_log(LOG_DEBUG, "bus WRITE @ %x (off %x) value %x\n", addr, off, val);