Skip to content
Permalink
Browse files
https://bugs.webkit.org/show_bug.cgi?id=45175
[WebView unmarkAllTextMatches] will crash if the webview is already closed

Reviewed by Dan Bernstein.

Made this and related methods robust against being called when the WebView is closed.

* WebView/WebView.mm:
(-[WebView markAllMatchesForText:caseSensitive:highlight:limit:]):
Bail out if the WebView is closed.
(-[WebView countMatchesForText:caseSensitive:highlight:limit:markMatches:]):
Ditto.
(-[WebView unmarkAllTextMatches]):
Ditto.
(-[WebView rectsForTextMatches]):
Ditto.



Canonical link: https://commits.webkit.org/57492@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@66733 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
John Sullivan committed Sep 3, 2010
1 parent df5098b commit 616cf4e41690b37d30b74238c0933f9128cd49a5
Showing 2 changed files with 31 additions and 0 deletions.
@@ -1,3 +1,22 @@
2010-09-03 John Sullivan <sullivan@apple.com>

Reviewed by Dan Bernstein.

https://bugs.webkit.org/show_bug.cgi?id=45175
[WebView unmarkAllTextMatches] will crash if the webview is already closed

Made this and related methods robust against being called when the WebView is closed.

* WebView/WebView.mm:
(-[WebView markAllMatchesForText:caseSensitive:highlight:limit:]):
Bail out if the WebView is closed.
(-[WebView countMatchesForText:caseSensitive:highlight:limit:markMatches:]):
Ditto.
(-[WebView unmarkAllTextMatches]):
Ditto.
(-[WebView rectsForTextMatches]):
Ditto.

2010-09-03 Hironori Bono <hbono@chromium.org>

Reviewed by Kent Tamura.
@@ -4380,11 +4380,17 @@ - (BOOL)canMarkAllTextMatches

- (NSUInteger)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(NSUInteger)limit
{
if (_private->closed)
return 0;

return [self countMatchesForText:string caseSensitive:caseFlag highlight:highlight limit:limit markMatches:YES];
}

- (NSUInteger)countMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(NSUInteger)limit markMatches:(BOOL)markMatches
{
if (_private->closed)
return 0;

WebFrame *frame = [self mainFrame];
unsigned matchCount = 0;
do {
@@ -4409,6 +4415,9 @@ - (NSUInteger)countMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFla

- (void)unmarkAllTextMatches
{
if (_private->closed)
return;

WebFrame *frame = [self mainFrame];
do {
id <WebDocumentView> view = [[frame frameView] documentView];
@@ -4421,6 +4430,9 @@ - (void)unmarkAllTextMatches

- (NSArray *)rectsForTextMatches
{
if (_private->closed)
return [NSArray array];

NSMutableArray *result = [NSMutableArray array];
WebFrame *frame = [self mainFrame];
do {

0 comments on commit 616cf4e

Please sign in to comment.