# HG changeset patch # User Michael Pavone # Date 1511756376 28800 # Node ID f29bd94ffa76c9e303cb722e66c61725f0df0451 # Parent 6a35815cc409c04e49e10909544459d19e7cdb1c Don't crash when keys are pressed before ROM is loaded diff -r 6a35815cc409 -r f29bd94ffa76 io.c --- a/io.c Sun Nov 26 20:17:22 2017 -0800 +++ b/io.c Sun Nov 26 20:19:36 2017 -0800 @@ -360,6 +360,9 @@ void handle_keydown(int keycode, uint8_t scancode) { + if (!current_io) { + return; + } int bucket = keycode >> 15 & 0xFFFF; int idx = keycode & 0x7FFF; keybinding * binding = bindings[bucket] ? bindings[bucket] + idx : NULL; @@ -564,6 +567,9 @@ void handle_keyup(int keycode, uint8_t scancode) { + if (!current_io) { + return; + } int bucket = keycode >> 15 & 0xFFFF; int idx = keycode & 0x7FFF; keybinding * binding = bindings[bucket] ? bindings[bucket] + idx : NULL;