yackle / CLImageEditor

MIT License
2.21k stars 574 forks source link

CRASH on deleting single character #236

Closed PulkitParangat closed 2 years ago

PulkitParangat commented 3 years ago

Select Text -> Click New -> type Qwerty. Now start deleting the characters. App will crash when you'll delete last character Q. Reason for crash is '-[__NSCFConstantString characterAtIndex:]: Range or index out of bounds'

in CLTextSettingView.m in -(void)textViewDidChange:(UITextView*)textView

Here's the line of code causing crash: (Line No. 304) if(selection.location+selection.length == textView.text.length && [textView.text characterAtIndex:textView.text.length-1] == '\n') {

rmaddy commented 3 years ago

I've just run into this issue. The problem also happens if you highlight all existing text and tap delete. The if statement needs to also ensure the text view has at least one character in it before trying to access the character at length - 1.

az-oolloow commented 2 years ago

We've run into the same issue :(

@yackle any chance that PR can be merged??

yackle commented 2 years ago

@az-oolloow Could you open PR on this repository?

cshcshan commented 2 years ago

@yackle I faced this issue too and open a PR at https://github.com/yackle/CLImageEditor/pull/238, please let me know if this could be merged