Skip to content

Commit

Permalink
7546: Dumb fix to prevent crash related to accessibility keyboard.
Browse files Browse the repository at this point in the history
Fixes brave/brave-browser#7546

Related upstream bugs:
https://bugs.chromium.org/p/chromium/issues/detail?id=1029719
https://bugs.chromium.org/p/chromium/issues/detail?id=1133086

It is pretty hard to craft a proper fix so we just add an extra
check and try to return quickly (along with sending a pseudo
crash dump).
  • Loading branch information
iefremov committed Dec 16, 2020
1 parent 464541e commit 864e291
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* Copyright (c) 2020 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "base/debug/dump_without_crashing.h"

#define BRAVE_FORPARAMETER \
if (startOffset < 0 || endOffset < 0) { \
base::debug::DumpWithoutCrashing(); \
return nil; \
}

#include "../../../../../../../content/browser/accessibility/browser_accessibility_cocoa.mm"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/content/browser/accessibility/browser_accessibility_cocoa.mm b/content/browser/accessibility/browser_accessibility_cocoa.mm
index d792b573258714648c8ce66bedc2fbb4e7417028..76bf56f79848d72067cee0835611962dc791cc55 100644
--- a/content/browser/accessibility/browser_accessibility_cocoa.mm
+++ b/content/browser/accessibility/browser_accessibility_cocoa.mm
@@ -3164,6 +3164,7 @@ id content::AXTextMarkerRangeFrom(id anchor_textmarker, id focus_textmarker) {
endObject = range.focus()->GetAnchor();
startOffset = range.anchor()->text_offset();
endOffset = range.focus()->text_offset();
+ BRAVE_FORPARAMETER
DCHECK(startObject && endObject);
DCHECK_GE(startOffset, 0);
DCHECK_GE(endOffset, 0);

0 comments on commit 864e291

Please sign in to comment.