Program: 198200
Project: 198200
Buggy source:
void saveToXml(XmlSerializer out) throws IOException, XmlPullParserException {
  if (ActivityManagerService.DEBUG_RECENTS)   Slog.i(TAG,"String_Node_Str" + this);
  out.attribute(null,ATTR_TASKID,String.valueOf(taskId));
  if (realActivity != null) {
    out.attribute(null,ATTR_REALACTIVITY,realActivity.flattenToShortString());
  }
  if (origActivity != null) {
    out.attribute(null,ATTR_ORIGACTIVITY,origActivity.flattenToShortString());
  }
  if (affinity != null) {
    out.attribute(null,ATTR_AFFINITY,affinity);
  }
  out.attribute(null,ATTR_ROOTHASRESET,String.valueOf(rootWasReset));
  out.attribute(null,ATTR_AUTOREMOVERECENTS,String.valueOf(autoRemoveRecents));
  out.attribute(null,ATTR_ASKEDCOMPATMODE,String.valueOf(askedCompatMode));
  out.attribute(null,ATTR_USERID,String.valueOf(userId));
  out.attribute(null,ATTR_TASKTYPE,String.valueOf(taskType));
  out.attribute(null,ATTR_FIRSTACTIVETIME,String.valueOf(firstActiveTime));
  out.attribute(null,ATTR_LASTACTIVETIME,String.valueOf(lastActiveTime));
  out.attribute(null,ATTR_LASTTIMEMOVED,String.valueOf(mLastTimeMoved));
  out.attribute(null,ATTR_NEVERRELINQUISH,String.valueOf(mNeverRelinquishIdentity));
  if (lastDescription != null) {
    out.attribute(null,ATTR_LASTDESCRIPTION,lastDescription.toString());
  }
  if (lastTaskDescription != null) {
    saveTaskDescription(lastTaskDescription,String.valueOf(taskId) + LAST_ACTIVITY_ICON_SUFFIX + lastActiveTime,out);
  }
  out.attribute(null,ATTR_TASK_AFFILIATION_COLOR,String.valueOf(mAffiliatedTaskColor));
  out.attribute(null,ATTR_TASK_AFFILIATION,String.valueOf(mAffiliatedTaskId));
  out.attribute(null,ATTR_PREV_AFFILIATION,String.valueOf(mPrevAffiliateTaskId));
  out.attribute(null,ATTR_NEXT_AFFILIATION,String.valueOf(mNextAffiliateTaskId));
  out.attribute(null,ATTR_CALLING_UID,String.valueOf(mCallingUid));
  out.attribute(null,ATTR_CALLING_PACKAGE,mCallingPackage == null ? "String_Node_Str" : mCallingPackage);
  if (affinityIntent != null) {
    out.startTag(null,TAG_AFFINITYINTENT);
    affinityIntent.saveToXml(out);
    out.endTag(null,TAG_AFFINITYINTENT);
  }
  out.startTag(null,TAG_INTENT);
  intent.saveToXml(out);
  out.endTag(null,TAG_INTENT);
  final ArrayList<ActivityRecord> activities=mActivities;
  final int numActivities=activities.size();
  for (int activityNdx=0; activityNdx < numActivities; ++activityNdx) {
    final ActivityRecord r=activities.get(activityNdx);
    if (r.info.persistableMode == ActivityInfo.PERSIST_ROOT_ONLY || !r.isPersistable() || ((r.intent.getFlags() & Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) != 0) && activityNdx > 0) {
      break;
    }
    out.startTag(null,TAG_ACTIVITY);
    r.saveToXml(out);
    out.endTag(null,TAG_ACTIVITY);
  }
}

Fixed version (ground truth):
void saveToXml(XmlSerializer out) throws IOException, XmlPullParserException {
  if (ActivityManagerService.DEBUG_RECENTS)   Slog.i(TAG,"String_Node_Str" + this);
  out.attribute(null,ATTR_TASKID,String.valueOf(taskId));
  if (realActivity != null) {
    out.attribute(null,ATTR_REALACTIVITY,realActivity.flattenToShortString());
  }
  if (origActivity != null) {
    out.attribute(null,ATTR_ORIGACTIVITY,origActivity.flattenToShortString());
  }
  if (affinity != null) {
    out.attribute(null,ATTR_AFFINITY,affinity);
  }
  out.attribute(null,ATTR_ROOTHASRESET,String.valueOf(rootWasReset));
  out.attribute(null,ATTR_AUTOREMOVERECENTS,String.valueOf(autoRemoveRecents));
  out.attribute(null,ATTR_ASKEDCOMPATMODE,String.valueOf(askedCompatMode));
  out.attribute(null,ATTR_USERID,String.valueOf(userId));
  out.attribute(null,ATTR_TASKTYPE,String.valueOf(taskType));
  out.attribute(null,ATTR_FIRSTACTIVETIME,String.valueOf(firstActiveTime));
  out.attribute(null,ATTR_LASTACTIVETIME,String.valueOf(lastActiveTime));
  out.attribute(null,ATTR_LASTTIMEMOVED,String.valueOf(mLastTimeMoved));
  out.attribute(null,ATTR_NEVERRELINQUISH,String.valueOf(mNeverRelinquishIdentity));
  if (lastDescription != null) {
    out.attribute(null,ATTR_LASTDESCRIPTION,lastDescription.toString());
  }
  if (lastTaskDescription != null) {
    saveTaskDescription(lastTaskDescription,createLastTaskDescriptionIconFilename(taskId,lastActiveTime),out);
  }
  out.attribute(null,ATTR_TASK_AFFILIATION_COLOR,String.valueOf(mAffiliatedTaskColor));
  out.attribute(null,ATTR_TASK_AFFILIATION,String.valueOf(mAffiliatedTaskId));
  out.attribute(null,ATTR_PREV_AFFILIATION,String.valueOf(mPrevAffiliateTaskId));
  out.attribute(null,ATTR_NEXT_AFFILIATION,String.valueOf(mNextAffiliateTaskId));
  out.attribute(null,ATTR_CALLING_UID,String.valueOf(mCallingUid));
  out.attribute(null,ATTR_CALLING_PACKAGE,mCallingPackage == null ? "String_Node_Str" : mCallingPackage);
  if (affinityIntent != null) {
    out.startTag(null,TAG_AFFINITYINTENT);
    affinityIntent.saveToXml(out);
    out.endTag(null,TAG_AFFINITYINTENT);
  }
  out.startTag(null,TAG_INTENT);
  intent.saveToXml(out);
  out.endTag(null,TAG_INTENT);
  final ArrayList<ActivityRecord> activities=mActivities;
  final int numActivities=activities.size();
  for (int activityNdx=0; activityNdx < numActivities; ++activityNdx) {
    final ActivityRecord r=activities.get(activityNdx);
    if (r.info.persistableMode == ActivityInfo.PERSIST_ROOT_ONLY || !r.isPersistable() || ((r.intent.getFlags() & Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) != 0) && activityNdx > 0) {
      break;
    }
    out.startTag(null,TAG_ACTIVITY);
    r.saveToXml(out);
    out.endTag(null,TAG_ACTIVITY);
  }
}