Description
The FastMpayScreen contains unsafe non-null assertions (!!) on nullable mutable Compose state variables inside conditional null checks.
Because these states are declared as mutable var Compose states, recomposition may occur between the null check and the !! dereference, causing the value to become null and resulting in a NullPointerException.
Location
feature/fast-mpay/src/commonMain/kotlin/org/mifospay/feature/fastmpay/FastMpayScreen.kt
Bank mismatch sheet
if (showBankMismatchSheet && bankMismatchData != null) {
val mismatchData = bankMismatchData!! // unsafe
}
Amount confirmation sheet
if (showAmountConfirmation && pendingAmountConfirmation != null) {
val pending = pendingAmountConfirmation!! // unsafe
}
Root Cause
bankMismatchData and pendingAmountConfirmation are mutable Compose states (var).
In Jetpack Compose, recomposition can happen between:
- the null check (
state != null)
- the
!! dereference
This creates a race condition where the value becomes null after the check but before dereferencing.
Steps to Reproduce
- Open FastMpay screen
- Scan a QR code from another bank (opens bank mismatch sheet)
- Trigger rapid recomposition/interactions while the sheet is rendering
- App crashes with
NullPointerException
Same issue can occur for the amount confirmation sheet.
Expected Behavior
The sheet should render safely or be skipped gracefully if the state becomes null.
Actual Behavior
Application crashes with NullPointerException.
Impact
Description
The
FastMpayScreencontains unsafe non-null assertions (!!) on nullable mutable Compose state variables inside conditional null checks.Because these states are declared as mutable
varCompose states, recomposition may occur between the null check and the!!dereference, causing the value to becomenulland resulting in aNullPointerException.Location
feature/fast-mpay/src/commonMain/kotlin/org/mifospay/feature/fastmpay/FastMpayScreen.ktBank mismatch sheet
Amount confirmation sheet
Root Cause
bankMismatchDataandpendingAmountConfirmationare mutable Compose states (var).In Jetpack Compose, recomposition can happen between:
state != null)!!dereferenceThis creates a race condition where the value becomes
nullafter the check but before dereferencing.Steps to Reproduce
NullPointerExceptionSame issue can occur for the amount confirmation sheet.
Expected Behavior
The sheet should render safely or be skipped gracefully if the state becomes
null.Actual Behavior
Application crashes with
NullPointerException.Impact
Affects all Compose targets: