Describe the bug
PostgresNumeric cannot decode large number (like 1234567890123) and it causes runtime crash.
To Reproduce
- call this line
PostgresNumeric(string: "1234567890123")
- crash!
Expected behavior
Can call initializer without crash.
Environment
- Vapor Framework version: 4.48.8
- postgres-nio: 1.6.2
Additional context
|
func reverseChunked(by maxSize: Int) -> [SubSequence] { |
this function does not work correctly and return values over maxSize.
let uuu = "1234567890123"
print(uuu.reverseChunked(by: 4)) // ["1", "2345", "67890", "123"]
then here, Int16(67890)! causes crash.
|
for chunk in integer.reverseChunked(by: 4) { |
|
weight += 1 |
|
// convert the 4 digits to an Int16 |
|
buffer.writeInteger(Int16(chunk)!, endianness: .big) |
|
} |
Describe the bug
PostgresNumericcannot decode large number (like1234567890123) and it causes runtime crash.To Reproduce
Expected behavior
Can call initializer without crash.
Environment
Additional context
postgres-nio/Sources/PostgresNIO/Data/PostgresData+Numeric.swift
Line 270 in 046d3ba
this function does not work correctly and return values over
maxSize.then here,
Int16(67890)!causes crash.postgres-nio/Sources/PostgresNIO/Data/PostgresData+Numeric.swift
Lines 91 to 95 in 046d3ba