From 92344ee3f306ecdfd1da4365ffc5cab6eaa29afd Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sun, 22 Mar 2015 18:17:06 +0100 Subject: Fix a wrap-around in skills menu The previous implementation would result in undefined behavior when wrapping around 0. --- src/skills.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/skills.cc') diff --git a/src/skills.cc b/src/skills.cc index 87aebd9c..787cbfa5 100644 --- a/src/skills.cc +++ b/src/skills.cc @@ -554,7 +554,7 @@ void do_cmd_skill() if (dir == 8) sel--; /* Miscellaneous skills cannot be increased/decreased as a group */ - if (table[sel][0] == SKILL_MISC) continue; + if ((sel >= 0) && (sel < max) && table[sel][0] == SKILL_MISC) continue; /* Increase the current skill */ if (dir == 6) increase_skill(table[sel][0], skill_invest.get()); -- cgit v1.2.3