Program: 192705
Project: 192705
Buggy source:
private void setTaskFromIntentActivity(ActivityRecord intentActivity){
  if ((mLaunchFlags & (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK)) == (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK)) {
    mReuseTask=intentActivity.task;
    mReuseTask.performClearTaskLocked();
    mReuseTask.setIntent(mStartActivity);
  }
 else   if ((mLaunchFlags & FLAG_ACTIVITY_CLEAR_TOP) != 0 || mLaunchSingleInstance || mLaunchSingleTask) {
    ActivityRecord top=intentActivity.task.performClearTaskLocked(mStartActivity,mLaunchFlags);
    if (top == null) {
      mAddingToTask=true;
      mSourceRecord=intentActivity;
      final TaskRecord task=mSourceRecord.task;
      if (task != null && task.stack == null) {
        mTargetStack=computeStackFocus(mSourceRecord,false,null,mLaunchFlags,mOptions);
        mTargetStack.addTask(task,!mLaunchTaskBehind,"String_Node_Str");
      }
    }
  }
 else   if (mStartActivity.realActivity.equals(intentActivity.task.realActivity)) {
    if (((mLaunchFlags & FLAG_ACTIVITY_SINGLE_TOP) != 0 || mLaunchSingleTop) && intentActivity.realActivity.equals(mStartActivity.realActivity)) {
      ActivityStack.logStartActivity(AM_NEW_INTENT,mStartActivity,intentActivity.task);
      if (intentActivity.frontOfTask) {
        intentActivity.task.setIntent(mStartActivity);
      }
      intentActivity.deliverNewIntentLocked(mCallingUid,mStartActivity.intent,mStartActivity.launchedFromPackage);
    }
 else     if (!mStartActivity.intent.filterEquals(intentActivity.task.intent)) {
      mAddingToTask=true;
      mSourceRecord=intentActivity;
    }
  }
 else   if ((mLaunchFlags & FLAG_ACTIVITY_RESET_TASK_IF_NEEDED) == 0) {
    mAddingToTask=true;
    mSourceRecord=intentActivity;
  }
 else   if (!intentActivity.task.rootWasReset) {
    intentActivity.task.setIntent(mStartActivity);
  }
}

Fixed version (ground truth):
private void setTaskFromIntentActivity(ActivityRecord intentActivity){
  if ((mLaunchFlags & (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK)) == (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK)) {
    mReuseTask=intentActivity.task;
    mReuseTask.performClearTaskLocked();
    mReuseTask.setIntent(mStartActivity);
  }
 else   if ((mLaunchFlags & FLAG_ACTIVITY_CLEAR_TOP) != 0 || mLaunchSingleInstance || mLaunchSingleTask) {
    ActivityRecord top=intentActivity.task.performClearTaskLocked(mStartActivity,mLaunchFlags);
    if (top == null) {
      mAddingToTask=true;
      mSourceRecord=intentActivity;
      final TaskRecord task=mSourceRecord.task;
      if (task != null && task.stack == null) {
        mTargetStack=computeStackFocus(mSourceRecord,false,null,mLaunchFlags,mOptions);
        mTargetStack.addTask(task,!mLaunchTaskBehind,"String_Node_Str");
      }
    }
  }
 else   if (mStartActivity.realActivity.equals(intentActivity.task.realActivity)) {
    if (((mLaunchFlags & FLAG_ACTIVITY_SINGLE_TOP) != 0 || mLaunchSingleTop) && intentActivity.realActivity.equals(mStartActivity.realActivity)) {
      ActivityStack.logStartActivity(AM_NEW_INTENT,mStartActivity,intentActivity.task);
      if (intentActivity.frontOfTask) {
        intentActivity.task.setIntent(mStartActivity);
      }
      intentActivity.deliverNewIntentLocked(mCallingUid,mStartActivity.intent,mStartActivity.launchedFromPackage);
    }
 else     if (!mStartActivity.intent.filterEquals(intentActivity.intent)) {
      mAddingToTask=true;
      mSourceRecord=intentActivity;
    }
  }
 else   if ((mLaunchFlags & FLAG_ACTIVITY_RESET_TASK_IF_NEEDED) == 0) {
    mAddingToTask=true;
    mSourceRecord=intentActivity;
  }
 else   if (!intentActivity.task.rootWasReset) {
    intentActivity.task.setIntent(mStartActivity);
  }
}