Bug 133659 - iOS WebKit: Crash in charactersAroundPosition
Summary: iOS WebKit: Crash in charactersAroundPosition
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: iPhone / iPad Unspecified
: P2 Normal
Assignee: Enrica Casucci
Keywords: InRadar
Depends on:
Reported: 2014-06-09 15:06 PDT by Enrica Casucci
Modified: 2014-06-09 16:20 PDT (History)
1 user (show)

See Also:

Patch (3.92 KB, patch)
2014-06-09 15:15 PDT, Enrica Casucci
benjamin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Enrica Casucci 2014-06-09 15:06:17 PDT
This is a crash introduced with http://trac.webkit.org/changeset/169500.

When we compute the editor state information we don't need to compute the charactersAroundPosition if we are not in editable content.

Comment 1 Enrica Casucci 2014-06-09 15:15:26 PDT
Created attachment 232737 [details]
Comment 2 WebKit Commit Bot 2014-06-09 15:16:32 PDT
Attachment 232737 [details] did not pass style-queue:

ERROR: Source/WebKit2/WebProcess/WebPage/WebPage.cpp:718:  Missing space before ( in if(  [whitespace/parens] [5]
Total errors found: 1 in 4 files

If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Enrica Casucci 2014-06-09 15:19:14 PDT
I've already fixed the style issue.
Comment 4 Benjamin Poulain 2014-06-09 15:21:39 PDT
Comment on attachment 232737 [details]

View in context: https://bugs.webkit.org/attachment.cgi?id=232737&action=review

> Source/WebCore/editing/VisibleUnits.cpp:1843
> +            if (index >= maxCharacters)
> +                break;

Shouldn't this be after "characters[index++] = characterString[i];".

You may want to change the for() loop into a while loop. Having a for() loop that breaks into the flow  tends to add complexity.
Comment 5 Enrica Casucci 2014-06-09 16:20:51 PDT
Committed revision 169728.