From 97452b6ec31d29a274da1b69b88d40707ce244ff Mon Sep 17 00:00:00 2001 From: Sintendo Date: Wed, 1 Apr 2020 00:06:00 +0200 Subject: [PATCH] settings/input: Fix updateControls crashes updateControls assumes that when activeMapping is set, an item from mappingList is guaranteed to be selected. However, there are several scenarios that break this assumption: - changing port during an active mapping - changing device during an active mapping - reloading the input driver during an active mapping In all of these cases, updateControls is eventually called. It sees an outstanding activeMapping and proceeds to figure out the offset of the currently selected item, but since there are no selected items it ends up dereferncing a null pointer. The assumption can be honored by having reloadMappings cancel the outstanding activeMapping, thus preventing a crash. Fixes #4. --- bsnes/target-bsnes/settings/input.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsnes/target-bsnes/settings/input.cpp b/bsnes/target-bsnes/settings/input.cpp index a056445a..13b04b7a 100644 --- a/bsnes/target-bsnes/settings/input.cpp +++ b/bsnes/target-bsnes/settings/input.cpp @@ -124,7 +124,7 @@ auto InputSettings::reloadMappings() -> void { for(uint n : range(BindingLimit)) item.append(TableViewCell()); } refreshMappings(); - updateControls(); + cancelMapping(); } auto InputSettings::refreshMappings() -> void {