check def_monsyms[], def_oc_syms[] index

Resolves #1179
This commit is contained in:
nhmall
2024-01-11 20:13:02 -05:00
parent 9a0f9b37cb
commit 213302d973
2 changed files with 7 additions and 2 deletions

View File

@@ -2619,6 +2619,8 @@ fix msg_window:combination and TTY getlin() ^P (pr #1155 by entrez)
remove a null sobj check from gold_detect that was situated after
dereferences had already been done (pr #1173 by argrath) and
adjust prototype in extern.h
check for valid indexes of def_monsyms[] and def_oc_syms[] in
choose_classes_menu() (pr #1179 by argrath)
Code Cleanup and Reorganization

View File

@@ -1665,10 +1665,12 @@ choose_classes_menu(const char *prompt,
start_menu(win, MENU_BEHAVE_STANDARD);
while (*class_list) {
int idx;
selected = FALSE;
switch (category) {
case 0:
if ((idx = def_char_to_monclass(*class_list)) == MAXMCLASSES) {
idx = def_char_to_monclass(*class_list);
if (!IndexOk(idx, def_monsyms)) {
panic("choose_classes_menu: invalid monclass '%c'", *class_list);
/*NOTREACHED*/
}
@@ -1677,7 +1679,8 @@ choose_classes_menu(const char *prompt,
Sprintf(buf, "%s", text);
break;
case 1:
if ((idx = def_char_to_objclass(*class_list)) == MAXOCLASSES) {
idx = def_char_to_objclass(*class_list);
if (!IndexOk(idx, def_oc_syms)) {
panic("choose_classes_menu: invalid objclass '%c'", *class_list);
/*NOTREACHED*/
}