From 060f84e07de983bc4ebf9077abc60a028de1c999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Kujawa?= Date: Wed, 13 Jun 2018 10:29:26 +0200 Subject: [PATCH] Fail if mapping exceeding the bus size --- src/bus.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bus.c b/src/bus.c index 68ebcd4..cfde423 100644 --- a/src/bus.c +++ b/src/bus.c @@ -27,10 +27,16 @@ bus_device_add(bus_t *b, device_t *d, uint16_t addr) { device_mapping_t *dm; + if ((addr + d->size) > RK65C02_BUS_SIZE) { + rk65c02_log(LOG_ERROR, + "Bus mapping for %s at %x, size %x exceeding bus size.", + d->name, addr, d->size); + return; + } + dm = (device_mapping_t *) GC_MALLOC(sizeof(device_mapping_t)); dm->dev = d; - /* TODO: check if addr + size is not bigger than RK65C02_BUS_SIZE */ dm->addr = addr; LL_APPEND((b->dm_head), dm);