From 33c13d6fffd7c94806c6bf6599ae43f9e7b887bc Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 2 Jan 2023 16:06:11 -0500 Subject: [PATCH] static analyzer bit display.c A static analyzer pointed out that the 'if' was checking for null pointer, but the 'else' was not, yet they were both then dereferencing the same variable. --- src/display.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/display.c b/src/display.c index 763777e3c..dd79340ea 100644 --- a/src/display.c +++ b/src/display.c @@ -2275,12 +2275,18 @@ get_bkglyph_and_framecolor(coordxy x, coordxy y, int *bkglyph, uint32 *framecolo if (idx != S_room) tmp_bkglyph = cmap_to_glyph(idx); } - if (gw.wsettings.map_frame_color != NO_COLOR && framecolor && mapxy_valid(x, y)) + *bkglyph = tmp_bkglyph; +#if 0 + /* this guard should be unnecessary */ + if (!framecolor) { + impossible("null framecolor passed to get_bkglyph_and_framecolor"); + return; + } +#endif + if (gw.wsettings.map_frame_color != NO_COLOR && mapxy_valid(x, y)) *framecolor = gw.wsettings.map_frame_color; else *framecolor = NO_COLOR; - - *bkglyph = tmp_bkglyph; } #if defined(TILES_IN_GLYPHMAP) && defined(MSDOS) -- 2.50.0