Fix reversed oveflow check.

This commit is contained in:
christos 2011-01-15 15:42:10 +00:00
parent b2b7e1871b
commit b163cf8017
1 changed files with 8 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: localtime.c,v 1.53 2011/01/15 12:31:57 martin Exp $ */
/* $NetBSD: localtime.c,v 1.54 2011/01/15 15:42:10 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
@ -10,7 +10,7 @@
#if 0
static char elsieid[] = "@(#)localtime.c 8.9";
#else
__RCSID("$NetBSD: localtime.c,v 1.53 2011/01/15 12:31:57 martin Exp $");
__RCSID("$NetBSD: localtime.c,v 1.54 2011/01/15 15:42:10 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -1704,8 +1704,10 @@ increment_overflow(int *number, int delta)
int number0;
number0 = *number;
if (delta < 0 ? number0 < INT_MIN - delta : INT_MAX - delta < number0)
return 1;
*number += delta;
return (*number < number0) != (delta < 0);
return 0;
}
static int
@ -1714,8 +1716,10 @@ long_increment_overflow(long *number, int delta)
long number0;
number0 = *number;
if (delta < 0 ? number0 < LONG_MIN - delta : LONG_MAX - delta < number0)
return 1;
*number += delta;
return (*number < number0) != (delta < 0);
return 0;
}
static int