Skip to content

Crash chuzzling an NSBigMutableString #3

@tgaul

Description

@tgaul

We encountered a crash in ChuzzleKit (as used by PromiseKit) when URL encoding a string that came out of a text field. The issue here is that for performance reasons, UIKit hands out a pointer to the internal mutable string representation (which can be an NSBigMutableString for long strings) and we were handing that to PromiseKit.

To fix this in our app, we made an immutable copy of the string we get from the text field and use that to call PromiseKit.

However, it would be best if PromiseKit didn't cause a crash if someone does this.

The 'crash' is the following exception at line 16 of Chuzzle.m (the mutable string copy line [(id)self setString:s];):

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: 'Attempt to mutate immutable object with replaceCharactersInRange:withString:'

You'd think an NSBigMutableString would be mutable based on its name, but apparently not in all cases (at least you can't always call setString: on it without this happening).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions