Crash during undo in UITextField.

Originator:henrycerner
Number:rdar://16570390 Date Originated:4/9/2014
Status:Open Resolved:
Product:iOS Product Version:5.0, 5.1
Classification:Crash/Hang/Data Loss Reproducible:Always
 
Summary:
Replacing a character with an empty string during textField:shouldChangeCharactersInRange:replacementString: and then undoing causes a crash.

This crash also occurs with UISearchBar's during searchBar:textDidChange: and searchBar:shouldChangeTextInRange:replacementText:

Steps to Reproduce:
1. Create a UITextField.  Make its delegate a view controller.
2. In said view controller, implement textField:shouldChangeCharactersInRange:replacementString:
3. In this methods implementation, set the textfields text property to be equal to its own text with double quotes removed.
4. Run the app.
5. Enter some text into the input box, then enter double quote, then enter more text.  Press undo twice and the app will crash.

Expected Results:
The app should not crash during an undo.

Actual Results:
The app crashes during undo.

Version:
iPhone Simulator, 7.0 (11A465)
Xcode Version 5.0 (5A1413)

Notes:
A sample application has been provided which reproduces the crash.

To crash using this sample, enter some text into the input box, then enter double quotes.  Then enter more text and then undo twice.  The app will crash.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!