From 48af4fa25969df9b6bcdb211b01c6cc53094279f Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 17 Feb 2018 18:54:52 -0800 Subject: [PATCH] static analyzer bit I can't find the original message at the moment, but one of the things that an analyzer complained about was the *s='\0' possibly assigning to a Null pointer. The superfluous test of 's' in the while condition has fooled it into thinking that's possible when it's not. if (s) { while (s && ...) { *s++ = ... } *s = '\0'; } --- src/hacklib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hacklib.c b/src/hacklib.c index a5d9d0c15..382551822 100644 --- a/src/hacklib.c +++ b/src/hacklib.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 hacklib.c $NHDT-Date: 1496860756 2017/06/07 18:39:16 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.50 $ */ +/* NetHack 3.6 hacklib.c $NHDT-Date: 1518922474 2018/02/18 02:54:34 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.54 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Robert Patrick Rankin, 1991 */ /* NetHack may be freely redistributed. See license for details. */ @@ -451,7 +451,7 @@ const char *stuff_to_strip, *orig; char *s = bp; if (s) { - while (s && *orig && i < (BUFSZ - 1)) { + while (*orig && i < (BUFSZ - 1)) { if (!index(stuff_to_strip, *orig)) { *s++ = *orig; i++;