From 6ccb56638a33d5e03e7989c4c7b581bf0d05ff79 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 6 May 2022 18:41:54 -0700 Subject: [PATCH] autounlock parsing confusion For char *next; don't compare (next = index(...)) != '\0'. '\0' has value 0 and 0 used in a pointer context is a null pointer. So the code worked as intended even though it wasn't written as what was intended. Fix: take off the char decoration. --- src/options.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/options.c b/src/options.c index 796935a72..743349bbb 100644 --- a/src/options.c +++ b/src/options.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 options.c $NHDT-Date: 1647472681 2022/03/16 23:18:01 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.542 $ */ +/* NetHack 3.7 options.c $NHDT-Date: 1651887695 2022/05/07 01:41:35 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.555 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2008. */ /* NetHack may be freely redistributed. See license for details. */ @@ -751,7 +751,7 @@ optfn_autounlock( sep = index(op, '+') ? '+' : ' '; while (op) { op = trimspaces(op); /* might have leading space */ - if ((nxt = index(op, sep)) != '\0') { + if ((nxt = index(op, sep)) != 0) { *nxt++ = '\0'; op = trimspaces(op); /* might have trailing space after * plus sign removal */