redo nowrap_add()
Yahoo!'s mailer delivered the report about nowrap_add() to my spam folder, apparently because it thinks that the signature attachments "may contain harmful content". :-( nowrap_add() checks for signed overflow after the fact, so after undefined behavior if that happens. This rewrites nowrap_add() and moves it from end.c to integer.h. I haven't generated any values big enough to exercise it, but the algorithm is straightforward so I'll take it on faith.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 end.c $NHDT-Date: 1711735821 2024/03/29 18:10:21 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.313 $ */
|
||||
/* NetHack 3.7 end.c $NHDT-Date: 1720397752 2024/07/08 00:15:52 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.315 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2012. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -15,10 +15,6 @@
|
||||
#endif
|
||||
#include "dlb.h"
|
||||
|
||||
|
||||
/* add b to long a, convert wraparound to max value */
|
||||
#define nowrap_add(a, b) (a = ((a + b) < 0 ? LONG_MAX : (a + b)))
|
||||
|
||||
#ifndef NO_SIGNAL
|
||||
staticfn void done_intr(int);
|
||||
# if defined(UNIX) || defined(VMS) || defined(__EMX__)
|
||||
|
||||
Reference in New Issue
Block a user