1. Peter Hosey
  2. ISO 8601 parser/unparser
Issue #6 new

Crash on dateFromString if string is nil

Mark Suman
created an issue

When calling ISO8601DateFormatter -dateFromString, an exception is thrown if string is nil. This crash does not happen with NSDateFormatter.

Works: {{{

!objective-c

NSDateFormatter dateFormatter = [[NSDateFormatter alloc] init]; NSDate nilDate = [dateFormatter dateFromString:nil]; }}}

Crashes: {{{

!objective-c

ISO8601DateFormatter dateFormatter = [[ISO8601DateFormatter alloc] init]; NSDate nilDate = [dateFormatter dateFromString:nil]; }}}

It crashes on line 165 when trying to skip leading whitespace.

Seems like checking for a nil string in -dateFromString:timeZone: and returning nil would suffice.

This crash also happens in -dateComponentsFromString:timeZone:range:.