Skip to content

Commit 85e767e

Browse files
committed
Fix: segfault when reading tin of NON_PM monster
This is yet another bug due to the failure to realize NON_PM is -1, not 0. Apparently this segfault would only happen when there is a NON_PM tin which is not spinach, which should not be possible as far as I know. Add an impossible case to handle that rather than letting it segfault.
1 parent 3e1fe5a commit 85e767e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/read.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,17 @@ tin_text(struct obj *tin, char* buf)
292292
if (food == HOMEMADE_TIN || !tin_msgs[msgidx]) {
293293
return (char *) 0;
294294
}
295-
if (tin->tinseed % 5 == 0 && tin->corpsenm) { /* be truthful */
295+
if (tin->tinseed % 5 == 0) { /* be truthful */
296296
msgidx = (tin->tinseed % NUM_MONST_LABELS) + LABEL_MONST_START;
297297
if (food == SPINACH_TIN) {
298298
Strcpy(format_arg, "spinach");
299-
} else {
299+
}
300+
else if (tin->corpsenm != NON_PM) {
300301
Strcpy(format_arg, mons[tin->corpsenm].pmnames[NEUTRAL]);
301302
}
303+
else {
304+
impossible("non-spinach tin with no corpsenm?");
305+
}
302306
}
303307
else { /* lie */
304308
if (msgidx == LABEL_BOGUSMON) {

0 commit comments

Comments
 (0)