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

Fatal error: Can't take a prefix of negative length from a collection #1907

Closed
buhikon opened this issue Nov 26, 2021 · 2 comments
Closed

Fatal error: Can't take a prefix of negative length from a collection #1907

buhikon opened this issue Nov 26, 2021 · 2 comments
Assignees
Labels
fixed in master Fixed in master, awaiting next update kind:bug triaged Issue has been reviewed by Stripe and is being tracked internally

Comments

@buhikon
Copy link

buhikon commented Nov 26, 2021

Summary

A crash occurred on STPFormTextField

Code to reproduce

  1. Launch a sample called UI Examples on iPad (device or simulator)
  2. Select the first cell (Card Field) from the table view on the main screen
  3. (a new view controller will be displayed, and a credit card text field will be automatically focused and a keyboard will appear)
  4. Tap a space bar in the keyboard
  5. Tap a backspace in the keyboard
  6. (crash)

iOS version

15.1

Installation method

Tested on the sample app

SDK version

21.9.0

Other information

(STPFormTextField.swift)

404        if deleting {
405            if let sanitized = unformattedString(for: textField.text) {
406                inputText = sanitized.stp_safeSubstring(to: sanitized.count - 1)
407            }
408        } else {

when the crash happens,

  • the value of textField.text is " " (Line 405)
  • sanitized is "" (Line 405)
  • it tries to call stp_safeSubstringfunc with -1 that makes the crash (Line 406)
@ramont-stripe ramont-stripe self-assigned this Nov 29, 2021
@ramont-stripe
Copy link
Contributor

@buhikon thank you for reporting this issue! I was able to reproduce it by following the provided steps. We are working on a fix for this.

@ramont-stripe ramont-stripe added kind:bug triaged Issue has been reviewed by Stripe and is being tracked internally fixed in master Fixed in master, awaiting next update labels Nov 29, 2021
@ramont-stripe
Copy link
Contributor

Hi @buhikon,

We just released a fix for this in v21.10.0. I'm closing this issue for now; feel free to re-open it if you are still experiencing this issue after upgrading.

Thank you again for reporting this and providing very detailed steps on how to reproduce it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in master Fixed in master, awaiting next update kind:bug triaged Issue has been reviewed by Stripe and is being tracked internally
Projects
None yet
Development

No branches or pull requests

2 participants