From: Michel Pollet <buserror@gmail.com>
Date: Mon, 6 Feb 2017 08:33:02 +0000 (+0000)
Subject: Added sanity check for the .mmcu section handlers
X-Git-Tag: v1.5~12
X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=d6a9c734250e8966d53d704279c8c450354bf152;p=sx%2Fsimavr.git

Added sanity check for the .mmcu section handlers

Manage to bite myself on this one.

Signed-off-by: Michel Pollet <buserror@gmail.com>
---

diff --git a/simavr/sim/sim_cmds.c b/simavr/sim/sim_cmds.c
index bb5f308..587f259 100644
--- a/simavr/sim/sim_cmds.c
+++ b/simavr/sim/sim_cmds.c
@@ -51,6 +51,12 @@ _avr_cmd_io_write(
 		}
 		command = &commands->table[v];
 	}
+	if (!command->handler) {
+		AVR_LOG(avr, LOG_ERROR, LOG_PREFIX
+			"%s: code 0x%02x has no handler (wrong MMCU config)\n",
+			__FUNCTION__, v);
+		return;
+	}
 
 	if (command) {
 		if (command->handler(avr, v, command->param))