mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Raise exception if smeone tries to initialise a date with NaN
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@26865 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ac3eb1fbce
commit
6f85f5292c
3 changed files with 17 additions and 0 deletions
|
@ -2,6 +2,9 @@
|
|||
|
||||
* Source/NSThread.m: add a couple of checks to ensure correct
|
||||
initialisation of class.
|
||||
* Source/NSDate.m:
|
||||
* Source/NSCalendarDate.m: Check for time interval since reference
|
||||
date being NaN, and raise an exception.
|
||||
|
||||
2008-09-21 00:05-EDT Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
|
|
|
@ -1511,6 +1511,12 @@ static inline int getDigits(const char *from, char *to, int limit, BOOL *error)
|
|||
*/
|
||||
- (id) initWithTimeIntervalSinceReferenceDate: (NSTimeInterval)seconds
|
||||
{
|
||||
if (isnan(seconds))
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@] interval is not a number",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
}
|
||||
_seconds_since_ref = seconds;
|
||||
if (_calendar_format == nil)
|
||||
{
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
|
||||
#include "GSPrivate.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
/* These constants seem to be what MacOS-X uses */
|
||||
#define DISTANT_FUTURE 63113990400.0
|
||||
#define DISTANT_PAST -63113817600.0
|
||||
|
@ -1354,6 +1356,12 @@ otherTime(NSDate* other)
|
|||
|
||||
- (id) initWithTimeIntervalSinceReferenceDate: (NSTimeInterval)secs
|
||||
{
|
||||
if (isnan(secs))
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@] interval is not a number",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
}
|
||||
_seconds_since_ref = secs;
|
||||
return self;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue