Skip to content

Commit

Permalink
Guard calls to save_card_delegate_.
Browse files Browse the repository at this point in the history
This change avoids calling methods on save_card_delegate_ when it is
unset to avoid crashing if save_card_delegate_ is unset. Say when the
bridge's methods are (incorrectly) called multiple times from Java.

This change addresses the immediate crash; for see
https://crbug.com/1488003 for root cause analysis.

(cherry picked from commit 7b9c09b)

Bug: 1484617
Change-Id: If59ecdfd55e60be71a2e4de608e32c6d0f35e936
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4902469
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Auto-Submit: Slobodan Pejic <slobodan@chromium.org>
Reviewed-by: Peter Kotwicz <pkotwicz@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1203425}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4903713
Reviewed-by: Stephen McGruer <smcgruer@chromium.org>
Commit-Queue: Slobodan Pejic <slobodan@chromium.org>
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/branch-heads/5993@{#1053}
Cr-Branched-From: 5113507-refs/heads/main@{#1192594}
  • Loading branch information
Slobodan Pejic authored and Chromium LUCI CQ committed Oct 2, 2023
1 parent 731fcef commit 537cfd7
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,29 @@ AutofillSaveCardBottomSheetBridge::AutofillSaveCardBottomSheetBridge(
java_autofill_save_card_bottom_sheet_bridge) {}

void AutofillSaveCardBottomSheetBridge::OnUiShown(JNIEnv* env) {
save_card_delegate_->OnUiShown();
if (save_card_delegate_) {
save_card_delegate_->OnUiShown();
}
}

void AutofillSaveCardBottomSheetBridge::OnUiAccepted(JNIEnv* env) {
save_card_delegate_->OnUiAccepted();
if (save_card_delegate_) {
save_card_delegate_->OnUiAccepted();
}
save_card_delegate_.reset(nullptr);
}

void AutofillSaveCardBottomSheetBridge::OnUiCanceled(JNIEnv* env) {
save_card_delegate_->OnUiCanceled();
if (save_card_delegate_) {
save_card_delegate_->OnUiCanceled();
}
save_card_delegate_.reset(nullptr);
}

void AutofillSaveCardBottomSheetBridge::OnUiIgnored(JNIEnv* env) {
save_card_delegate_->OnUiIgnored();
if (save_card_delegate_) {
save_card_delegate_->OnUiIgnored();
}
save_card_delegate_.reset(nullptr);
}

Expand Down

0 comments on commit 537cfd7

Please sign in to comment.