UltraRogue: prevent bad array accesses in call().
Marking non-magic items caused segfaults because item_color was set to NULL. item_type could also be used as an out-of-bounds index. These problems have been fixed by only using these variables when the mark argument is false, in which case they are properly initialized. A fall-through case statement was also fixed.
This commit is contained in:
parent
b521be16e8
commit
6164897cfc
1 changed files with 5 additions and 4 deletions
|
|
@ -1303,6 +1303,7 @@ call(int mark)
|
||||||
case STICK:
|
case STICK:
|
||||||
item_type = TYP_STICK;
|
item_type = TYP_STICK;
|
||||||
item_color = ws_made;
|
item_color = ws_made;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if (!mark)
|
if (!mark)
|
||||||
{
|
{
|
||||||
|
|
@ -1312,10 +1313,7 @@ call(int mark)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
elsewise = (guess_items[item_type][obj->o_which] != NULL ?
|
if (!mark && know_items[item_type][obj->o_which])
|
||||||
guess_items[item_type][obj->o_which] : item_color[obj->o_which]);
|
|
||||||
|
|
||||||
if (know_items[item_type][obj->o_which] && !mark)
|
|
||||||
{
|
{
|
||||||
msg("That has already been identified.");
|
msg("That has already been identified.");
|
||||||
return;
|
return;
|
||||||
|
|
@ -1331,6 +1329,9 @@ call(int mark)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
elsewise = (guess_items[item_type][obj->o_which] != NULL ?
|
||||||
|
guess_items[item_type][obj->o_which] : item_color[obj->o_which]);
|
||||||
|
|
||||||
msg("Was called \"%s\".", elsewise);
|
msg("Was called \"%s\".", elsewise);
|
||||||
msg("What do you want to call it? ");
|
msg("What do you want to call it? ");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue