From 78b012a680c489082a61886ab07ec66cee643d08 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sat, 18 Apr 2015 15:29:37 -0400 Subject: [PATCH] prevent a couple of reported array index segfaults Changes to be committed: modified: src/hack.c modified: src/pager.c Don't use glyph_to_cmap as an array index into the defsyms[] array unless it really is a cmap. Recent situation: glyph_to_cmap will return NO_GLYPH for the unknown monster glyph 'I', which is not a valid index for the defsyms[] array. --- src/hack.c | 2 +- src/pager.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hack.c b/src/hack.c index df437391a..c94363d91 100644 --- a/src/hack.c +++ b/src/hack.c @@ -1363,7 +1363,7 @@ domove() if (boulder) Strcpy(buf, ansimpleoname(boulder)); - else if (solid) + else if (solid && glyph_is_cmap(glyph)) Strcpy(buf, the(defsyms[glyph_to_cmap(glyph)].explanation)); else if (!Underwater) Strcpy(buf, "thin air"); diff --git a/src/pager.c b/src/pager.c index 280cf0a05..e8d7c168b 100644 --- a/src/pager.c +++ b/src/pager.c @@ -273,7 +273,8 @@ lookat(x, y, buf, monbuf) Strcpy(buf, Is_airlevel(&u.uz) ? "cloudy area" : "fog/vapor cloud"); break; default: - Strcpy(buf,defsyms[glyph_to_cmap(glyph)].explanation); + if (glyph_is_cmap(glyph)) + Strcpy(buf,defsyms[glyph_to_cmap(glyph)].explanation); break; }