Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: content/browser/accessibility/browser_accessibility_cocoa.mm

Issue 2396593002: Merge to M54: Temporarily work around crash when adding misspelling annotations to accessible strin… (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/accessibility/browser_accessibility_cocoa.mm
diff --git a/content/browser/accessibility/browser_accessibility_cocoa.mm b/content/browser/accessibility/browser_accessibility_cocoa.mm
index b6d73a815fff640a1df856ecb587d1396f53aafc..6c7d1564febc820c4d27fcb43f2e5e7cba06abf5 100644
--- a/content/browser/accessibility/browser_accessibility_cocoa.mm
+++ b/content/browser/accessibility/browser_accessibility_cocoa.mm
@@ -290,6 +290,13 @@ NSAttributedString* GetAttributedTextForTextMarkerRange(
trim_length = static_cast<int>(end_object->GetText().length()) - end_offset;
}
int range_length = [text length] - start_offset - trim_length;
+
+ // http://crbug.com/651145
+ // This shouldn't happen, so this is a temporary workaround to prevent
+ // hard crashes.
+ if (range_length < 0)
+ return nil;
+
DCHECK_GE(range_length, 0);
NSRange range = NSMakeRange(start_offset, range_length);
DCHECK_LE(NSMaxRange(range), [text length]);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698