Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 865a7f83 authored by Mark Lu's avatar Mark Lu Committed by Steve Kondik
Browse files

[ActivityManager] fix NPE in ActivityStack.resetTargetTaskIfNeededLocked.

Symptom:
in .ActivityStack.resetTargetTaskIfNeededLocked,  "allowTaskReparenting" if case will call setTask
to remove activities from task, that will caused numActivities in main for-loop not consist with task.mActivities size.
caused NPE will happend in finish activities for-loop due to get null object from activities when clearWhenTaskReset" as true case.

Root Cause:
when clearWhenTaskReset as true, will set "end" variable as numActivities -1, but if calling setTask to remove activities from task,
end value will out of date & not same with task.mActivities size.

Solution:
use activities.size() - 1 to assign end value.

Change-Id: I5d7fe22e1df2fc61738db23402e7c42cf6d8c4cc
parent c3cc261d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2303,7 +2303,7 @@ final class ActivityStack {
                    // In this case, we want to finish this activity
                    // and everything above it, so be sneaky and pretend
                    // like these are all in the reply chain.
                    end = numActivities - 1;
                    end = activities.size() - 1;
                } else if (replyChainEnd < 0) {
                    end = i;
                } else {