Skip to content

Commit

Permalink
fix: handle null internal config in args for HCaptchaDialogFragment (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
CAMOBAP authored Dec 23, 2023
1 parent cca93c1 commit c3ed955
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions sdk/src/main/java/com/hcaptcha/sdk/HCaptchaDialogFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,17 @@ public View onCreateView(@Nullable LayoutInflater inflater,
HCaptchaStateListener listener = null;
try {
final Bundle args = getArguments();
assert args != null;
listener = HCaptchaCompat.getParcelable(args, KEY_LISTENER, HCaptchaStateListener.class);
assert listener != null;
final HCaptchaConfig config = HCaptchaCompat.getSerializable(args, KEY_CONFIG, HCaptchaConfig.class);
assert config != null;
final HCaptchaInternalConfig internalConfig = HCaptchaCompat.getSerializable(args,
KEY_INTERNAL_CONFIG, HCaptchaInternalConfig.class);
assert internalConfig != null;

if (listener == null || config == null || internalConfig == null) {
// According to Firebase Analytics, there are cases where Bundle args are empty.
// > 90% of these cases occur on Android 6, and the count of crashes <<< the count of sessions.
// This is a quick fix to prevent crashes in production
throw new AssertionError();
}

if (inflater == null) {
throw new InflateException("inflater is null");
Expand Down

0 comments on commit c3ed955

Please sign in to comment.