Commit 211e3f60 authored by Rouslan Solomakhin's avatar Rouslan Solomakhin Committed by Commit Bot

[Web Payment][Android] Check for null pointers.

Before this patch, a null payment method section or unselected payment
instrument could result in a NullPointerException inside of the
isMicrotransactionUiApplicable() method in PaymentRequestImpl.

This patch null-checks the payment method section and the selected
payment instrument before accessing them.

After this patch, isMicrotransactionUiApplicable() will not throw
NullPointerException.

Bug: 1046938
Change-Id: I14335effa84c5ca44a2de960f63e25fe3eb5ee2e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2033676
Auto-Submit: Rouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Reviewed-by: default avatarLiquan (Max) Gu <maxlg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738331}
parent 420a64f6
...@@ -1093,10 +1093,13 @@ public class PaymentRequestImpl ...@@ -1093,10 +1093,13 @@ public class PaymentRequestImpl
/** @return Whether the microtransaction UI should be shown. */ /** @return Whether the microtransaction UI should be shown. */
private boolean isMicrotransactionUiApplicable() { private boolean isMicrotransactionUiApplicable() {
if (!mIsUserGestureShow || mPaymentMethodsSection.getSize() != 1) return false; if (!mIsUserGestureShow || mPaymentMethodsSection == null
|| mPaymentMethodsSection.getSize() != 1) {
return false;
}
PaymentInstrument instrument = (PaymentInstrument) mPaymentMethodsSection.getSelectedItem(); PaymentInstrument instrument = (PaymentInstrument) mPaymentMethodsSection.getSelectedItem();
if (!instrument.isReadyForMicrotransaction() if (instrument == null || !instrument.isReadyForMicrotransaction()
|| TextUtils.isEmpty(instrument.accountBalance())) { || TextUtils.isEmpty(instrument.accountBalance())) {
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment