From 57a142b76fecc15aa0bdb08a85241910c9055462 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sat, 8 Feb 2014 19:33:50 -0500 Subject: [PATCH] fix logic/crash in CoinModeNoHome option This option was returning -1 for an index and triggering an assert, and the logic in the other direction was typoed. --- src/ScreenOptionsMasterPrefs.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ScreenOptionsMasterPrefs.cpp b/src/ScreenOptionsMasterPrefs.cpp index 211b227ed7..d4fb9bf5e6 100644 --- a/src/ScreenOptionsMasterPrefs.cpp +++ b/src/ScreenOptionsMasterPrefs.cpp @@ -390,12 +390,17 @@ static void CoinModeNoHome( int &sel, bool ToSel, const ConfOption *pConfOption if( ToSel ) { MovePref( sel, ToSel, pConfOption ); - sel--; + // If the mode was Pay, the index is 0; otherwise, set the index + // to 1 to avoid out-of-range crashing. + if (sel == 1) + sel = 0; + else + sel = 1; } else { int tmp = sel + 1; - MovePref( sel, ToSel, pConfOption ); + MovePref( tmp, ToSel, pConfOption ); } }