Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime crush at PostgresNumeric.init #186

Open
sidepelican opened this issue Oct 11, 2021 · 0 comments · May be fixed by #187
Open

Runtime crush at PostgresNumeric.init #186

sidepelican opened this issue Oct 11, 2021 · 0 comments · May be fixed by #187
Labels
bug Something isn't working

Comments

@sidepelican
Copy link
Contributor

sidepelican commented Oct 11, 2021

Describe the bug

PostgresNumeric cannot decode large number (like 1234567890123) and it causes runtime crash.

To Reproduce

  1. call this line
PostgresNumeric(string: "1234567890123")
  1. 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)
}

@sidepelican sidepelican added the bug Something isn't working label Oct 11, 2021
@sidepelican sidepelican linked a pull request Oct 11, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant