apple / swift-foundation

The Foundation project
Apache License 2.0
2.29k stars 135 forks source link

Prevent `IntegerParseStrategy` from crashing when encountering OOB numbers #658

Closed jmschonfeld closed 1 month ago

jmschonfeld commented 1 month ago

Internally, IntegerParseStrategy currently parses as Int64 or Double (since that's what ICU supports) and then casts to the format output type. However, if the format output type is an unsigned integer or an integer of width less than 64 bits, this causes a crash. We should instead detect this and throw an error during parsing if the parsed number does not fit within the bounds of the specified output type.

Resolves rdar://129237031

jmschonfeld commented 1 month ago

@swift-ci please test