Skip to content

Commit

Permalink
Ignore the invalid offset instead of crash
Browse files Browse the repository at this point in the history
Bug: 1496460
Change-Id: I1c8d74dfd9bb9e7923a8aed86b08da8b34beb152
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4984492
Reviewed-by: Jinsuk Kim <jinsukkim@chromium.org>
Commit-Queue: Gang Wu <gangwu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1216733}
  • Loading branch information
Gang Wu authored and Chromium LUCI CQ committed Oct 30, 2023
1 parent a7969b7 commit 9397594
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "content/public/android/content_jni_headers/SelectionPopupControllerImpl_jni.h"
#include "content/public/browser/context_menu_params.h"
#include "content/public/common/content_features.h"
#include "mojo/public/cpp/bindings/message.h"
#include "third_party/blink/public/common/context_menu_data/edit_flags.h"
#include "third_party/blink/public/mojom/context_menu/context_menu.mojom.h"
#include "third_party/blink/public/mojom/input/input_handler.mojom-blink.h"
Expand Down Expand Up @@ -278,15 +277,11 @@ void SelectionPopupController::OnSelectAroundCaretAck(
if (obj.is_null()) {
return;
}
if (result.is_null()) {
if (result.is_null() || !IsOffsetAdjustValid(startOffset, endOffset,
surroundingTextLength, result)) {
Java_SelectionPopupControllerImpl_onSelectAroundCaretFailure(env, obj);
return;
}
if (!IsOffsetAdjustValid(startOffset, endOffset, surroundingTextLength,
result)) {
mojo::ReportBadMessage("SelectAroundCaretResult's offset is invalid.");
return;
}

Java_SelectionPopupControllerImpl_onSelectAroundCaretSuccess(
env, obj, result->extended_start_adjust, result->extended_end_adjust,
Expand Down

0 comments on commit 9397594

Please sign in to comment.