Skip to content

Commit 258029e

Browse files
committed
Fix potential NPE when saving fragment state.
If a fragment's saved view state is null and the user visible hint is true then the `result` bundle will have never been initialized to a value resulting in a `NullPointerException`. Mirrors support library change I8ba585bc6b9298841490d64bc22a8219cd261adb. Change-Id: Iabd5ac293d2ece3771da9ef257479eca0dcd523c
1 parent fee88fd commit 258029e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

core/java/android/app/FragmentManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,9 @@ Bundle saveFragmentBasicState(Fragment f) {
15381538
FragmentManagerImpl.VIEW_STATE_TAG, f.mSavedViewState);
15391539
}
15401540
if (!f.mUserVisibleHint) {
1541+
if (result == null) {
1542+
result = new Bundle();
1543+
}
15411544
// Only add this if it's not the default value
15421545
result.putBoolean(FragmentManagerImpl.USER_VISIBLE_HINT_TAG, f.mUserVisibleHint);
15431546
}

0 commit comments

Comments
 (0)