Program: 785
Project: 785
Buggy source:
private void readPackageLPw(XmlPullParser parser) throws XmlPullParserException, IOException {
  String name=null;
  String realName=null;
  String idStr=null;
  String sharedIdStr=null;
  String codePathStr=null;
  String resourcePathStr=null;
  String nativeLibraryPathStr=null;
  String systemStr=null;
  String installerPackageName=null;
  String uidError=null;
  int pkgFlags=0;
  long timeStamp=0;
  long firstInstallTime=0;
  long lastUpdateTime=0;
  PackageSettingBase packageSetting=null;
  String version=null;
  int versionCode=0;
  try {
    name=parser.getAttributeValue(null,ATTR_NAME);
    realName=parser.getAttributeValue(null,"String_Node_Str");
    idStr=parser.getAttributeValue(null,"String_Node_Str");
    uidError=parser.getAttributeValue(null,"String_Node_Str");
    sharedIdStr=parser.getAttributeValue(null,"String_Node_Str");
    codePathStr=parser.getAttributeValue(null,"String_Node_Str");
    resourcePathStr=parser.getAttributeValue(null,"String_Node_Str");
    nativeLibraryPathStr=parser.getAttributeValue(null,"String_Node_Str");
    version=parser.getAttributeValue(null,"String_Node_Str");
    if (version != null) {
      try {
        versionCode=Integer.parseInt(version);
      }
 catch (      NumberFormatException e) {
      }
    }
    installerPackageName=parser.getAttributeValue(null,"String_Node_Str");
    systemStr=parser.getAttributeValue(null,"String_Node_Str");
    if (systemStr != null) {
      try {
        pkgFlags=Integer.parseInt(systemStr);
      }
 catch (      NumberFormatException e) {
      }
    }
 else {
      systemStr=parser.getAttributeValue(null,"String_Node_Str");
      if (systemStr != null) {
        pkgFlags|=("String_Node_Str".equalsIgnoreCase(systemStr)) ? ApplicationInfo.FLAG_SYSTEM : 0;
      }
 else {
        pkgFlags|=ApplicationInfo.FLAG_SYSTEM;
      }
    }
    String timeStampStr=parser.getAttributeValue(null,"String_Node_Str");
    if (timeStampStr != null) {
      try {
        timeStamp=Long.parseLong(timeStampStr,16);
      }
 catch (      NumberFormatException e) {
      }
    }
 else {
      timeStampStr=parser.getAttributeValue(null,"String_Node_Str");
      if (timeStampStr != null) {
        try {
          timeStamp=Long.parseLong(timeStampStr);
        }
 catch (        NumberFormatException e) {
        }
      }
    }
    timeStampStr=parser.getAttributeValue(null,"String_Node_Str");
    if (timeStampStr != null) {
      try {
        firstInstallTime=Long.parseLong(timeStampStr,16);
      }
 catch (      NumberFormatException e) {
      }
    }
    timeStampStr=parser.getAttributeValue(null,"String_Node_Str");
    if (timeStampStr != null) {
      try {
        lastUpdateTime=Long.parseLong(timeStampStr,16);
      }
 catch (      NumberFormatException e) {
      }
    }
    if (PackageManagerService.DEBUG_SETTINGS)     Log.v(PackageManagerService.TAG,"String_Node_Str" + name + "String_Node_Str"+ idStr+ "String_Node_Str"+ sharedIdStr);
    int userId=idStr != null ? Integer.parseInt(idStr) : 0;
    if (resourcePathStr == null) {
      resourcePathStr=codePathStr;
    }
    if (realName != null) {
      realName=realName.intern();
    }
    if (name == null) {
      PackageManagerService.reportSettingsProblem(Log.WARN,"String_Node_Str" + parser.getPositionDescription());
    }
 else     if (codePathStr == null) {
      PackageManagerService.reportSettingsProblem(Log.WARN,"String_Node_Str" + parser.getPositionDescription());
    }
 else     if (userId > 0) {
      packageSetting=addPackageLPw(name.intern(),realName,new File(codePathStr),new File(resourcePathStr),nativeLibraryPathStr,userId,versionCode,pkgFlags);
      if (PackageManagerService.DEBUG_SETTINGS)       Log.i(PackageManagerService.TAG,"String_Node_Str" + name + "String_Node_Str"+ userId+ "String_Node_Str"+ packageSetting);
      if (packageSetting == null) {
        PackageManagerService.reportSettingsProblem(Log.ERROR,"String_Node_Str" + userId + "String_Node_Str"+ parser.getPositionDescription());
      }
 else {
        packageSetting.setTimeStamp(timeStamp);
        packageSetting.firstInstallTime=firstInstallTime;
        packageSetting.lastUpdateTime=lastUpdateTime;
      }
    }
 else     if (sharedIdStr != null) {
      userId=sharedIdStr != null ? Integer.parseInt(sharedIdStr) : 0;
      if (userId > 0) {
        packageSetting=new PendingPackage(name.intern(),realName,new File(codePathStr),new File(resourcePathStr),nativeLibraryPathStr,userId,versionCode,pkgFlags);
        packageSetting.setTimeStamp(timeStamp);
        packageSetting.firstInstallTime=firstInstallTime;
        packageSetting.lastUpdateTime=lastUpdateTime;
        mPendingPackages.add((PendingPackage)packageSetting);
        if (PackageManagerService.DEBUG_SETTINGS)         Log.i(PackageManagerService.TAG,"String_Node_Str" + name + "String_Node_Str"+ userId+ "String_Node_Str"+ packageSetting);
      }
 else {
        PackageManagerService.reportSettingsProblem(Log.WARN,"String_Node_Str" + name + "String_Node_Str"+ sharedIdStr+ "String_Node_Str"+ parser.getPositionDescription());
      }
    }
 else {
      PackageManagerService.reportSettingsProblem(Log.WARN,"String_Node_Str" + name + "String_Node_Str"+ idStr+ "String_Node_Str"+ parser.getPositionDescription());
    }
  }
 catch (  NumberFormatException e) {
    PackageManagerService.reportSettingsProblem(Log.WARN,"String_Node_Str" + name + "String_Node_Str"+ idStr+ "String_Node_Str"+ parser.getPositionDescription());
  }
  if (packageSetting != null) {
    packageSetting.uidError="String_Node_Str".equals(uidError);
    packageSetting.installerPackageName=installerPackageName;
    packageSetting.nativeLibraryPathString=nativeLibraryPathStr;
    final String enabledStr=parser.getAttributeValue(null,ATTR_ENABLED);
    if (enabledStr != null) {
      try {
        packageSetting.setEnabled(Integer.parseInt(enabledStr),0,null);
      }
 catch (      NumberFormatException e) {
        if (enabledStr.equalsIgnoreCase("String_Node_Str")) {
          packageSetting.setEnabled(COMPONENT_ENABLED_STATE_ENABLED,0,null);
        }
 else         if (enabledStr.equalsIgnoreCase("String_Node_Str")) {
          packageSetting.setEnabled(COMPONENT_ENABLED_STATE_DISABLED,0,null);
        }
 else         if (enabledStr.equalsIgnoreCase("String_Node_Str")) {
          packageSetting.setEnabled(COMPONENT_ENABLED_STATE_DEFAULT,0,null);
        }
 else {
          PackageManagerService.reportSettingsProblem(Log.WARN,"String_Node_Str" + name + "String_Node_Str"+ idStr+ "String_Node_Str"+ parser.getPositionDescription());
        }
      }
    }
 else {
      packageSetting.setEnabled(COMPONENT_ENABLED_STATE_DEFAULT,0,null);
    }
    final String installStatusStr=parser.getAttributeValue(null,"String_Node_Str");
    if (installStatusStr != null) {
      if (installStatusStr.equalsIgnoreCase("String_Node_Str")) {
        packageSetting.installStatus=PackageSettingBase.PKG_INSTALL_INCOMPLETE;
      }
 else {
        packageSetting.installStatus=PackageSettingBase.PKG_INSTALL_COMPLETE;
      }
    }
    int outerDepth=parser.getDepth();
    int type;
    while ((type=parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
      if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
        continue;
      }
      String tagName=parser.getName();
      if (tagName.equals(TAG_DISABLED_COMPONENTS)) {
        readDisabledComponentsLPw(packageSetting,parser,0);
      }
 else       if (tagName.equals(TAG_ENABLED_COMPONENTS)) {
        readEnabledComponentsLPw(packageSetting,parser,0);
      }
 else       if (tagName.equals("String_Node_Str")) {
        packageSetting.signatures.readXml(parser,mPastSignatures);
      }
 else       if (tagName.equals("String_Node_Str")) {
        readGrantedPermissionsLPw(parser,packageSetting.grantedPermissions);
        packageSetting.permissionsFixed=true;
      }
 else       if (tagName.equals("String_Node_Str")) {
        long id=Long.parseLong(parser.getAttributeValue(null,"String_Node_Str"));
        packageSetting.keySetData.addSigningKeySet(id);
        Slog.d(TAG,"String_Node_Str" + Long.toString(id) + "String_Node_Str"+ name);
      }
 else       if (tagName.equals("String_Node_Str")) {
        long id=Long.parseLong(parser.getAttributeValue(null,"String_Node_Str"));
        String alias=parser.getAttributeValue(null,"String_Node_Str");
        packageSetting.keySetData.addDefinedKeySet(id,alias);
      }
 else {
        PackageManagerService.reportSettingsProblem(Log.WARN,"String_Node_Str" + parser.getName());
        XmlUtils.skipCurrentTag(parser);
      }
    }
  }
 else {
    XmlUtils.skipCurrentTag(parser);
  }
}

Fixed version (ground truth):
private void readPackageLPw(XmlPullParser parser) throws XmlPullParserException, IOException {
  String name=null;
  String realName=null;
  String idStr=null;
  String sharedIdStr=null;
  String codePathStr=null;
  String resourcePathStr=null;
  String nativeLibraryPathStr=null;
  String systemStr=null;
  String installerPackageName=null;
  String uidError=null;
  int pkgFlags=0;
  long timeStamp=0;
  long firstInstallTime=0;
  long lastUpdateTime=0;
  PackageSettingBase packageSetting=null;
  String version=null;
  int versionCode=0;
  try {
    name=parser.getAttributeValue(null,ATTR_NAME);
    realName=parser.getAttributeValue(null,"String_Node_Str");
    idStr=parser.getAttributeValue(null,"String_Node_Str");
    uidError=parser.getAttributeValue(null,"String_Node_Str");
    sharedIdStr=parser.getAttributeValue(null,"String_Node_Str");
    codePathStr=parser.getAttributeValue(null,"String_Node_Str");
    resourcePathStr=parser.getAttributeValue(null,"String_Node_Str");
    nativeLibraryPathStr=parser.getAttributeValue(null,"String_Node_Str");
    version=parser.getAttributeValue(null,"String_Node_Str");
    if (version != null) {
      try {
        versionCode=Integer.parseInt(version);
      }
 catch (      NumberFormatException e) {
      }
    }
    installerPackageName=parser.getAttributeValue(null,"String_Node_Str");
    systemStr=parser.getAttributeValue(null,"String_Node_Str");
    if (systemStr != null) {
      try {
        pkgFlags=Integer.parseInt(systemStr);
      }
 catch (      NumberFormatException e) {
      }
    }
 else {
      systemStr=parser.getAttributeValue(null,"String_Node_Str");
      if (systemStr != null) {
        pkgFlags|=("String_Node_Str".equalsIgnoreCase(systemStr)) ? ApplicationInfo.FLAG_SYSTEM : 0;
      }
 else {
        pkgFlags|=ApplicationInfo.FLAG_SYSTEM;
      }
    }
    String timeStampStr=parser.getAttributeValue(null,"String_Node_Str");
    if (timeStampStr != null) {
      try {
        timeStamp=Long.parseLong(timeStampStr,16);
      }
 catch (      NumberFormatException e) {
      }
    }
 else {
      timeStampStr=parser.getAttributeValue(null,"String_Node_Str");
      if (timeStampStr != null) {
        try {
          timeStamp=Long.parseLong(timeStampStr);
        }
 catch (        NumberFormatException e) {
        }
      }
    }
    timeStampStr=parser.getAttributeValue(null,"String_Node_Str");
    if (timeStampStr != null) {
      try {
        firstInstallTime=Long.parseLong(timeStampStr,16);
      }
 catch (      NumberFormatException e) {
      }
    }
    timeStampStr=parser.getAttributeValue(null,"String_Node_Str");
    if (timeStampStr != null) {
      try {
        lastUpdateTime=Long.parseLong(timeStampStr,16);
      }
 catch (      NumberFormatException e) {
      }
    }
    if (PackageManagerService.DEBUG_SETTINGS)     Log.v(PackageManagerService.TAG,"String_Node_Str" + name + "String_Node_Str"+ idStr+ "String_Node_Str"+ sharedIdStr);
    int userId=idStr != null ? Integer.parseInt(idStr) : 0;
    if (resourcePathStr == null) {
      resourcePathStr=codePathStr;
    }
    if (realName != null) {
      realName=realName.intern();
    }
    if (name == null) {
      PackageManagerService.reportSettingsProblem(Log.WARN,"String_Node_Str" + parser.getPositionDescription());
    }
 else     if (codePathStr == null) {
      PackageManagerService.reportSettingsProblem(Log.WARN,"String_Node_Str" + parser.getPositionDescription());
    }
 else     if (userId > 0) {
      packageSetting=addPackageLPw(name.intern(),realName,new File(codePathStr),new File(resourcePathStr),nativeLibraryPathStr,userId,versionCode,pkgFlags);
      if (PackageManagerService.DEBUG_SETTINGS)       Log.i(PackageManagerService.TAG,"String_Node_Str" + name + "String_Node_Str"+ userId+ "String_Node_Str"+ packageSetting);
      if (packageSetting == null) {
        PackageManagerService.reportSettingsProblem(Log.ERROR,"String_Node_Str" + userId + "String_Node_Str"+ parser.getPositionDescription());
      }
 else {
        packageSetting.setTimeStamp(timeStamp);
        packageSetting.firstInstallTime=firstInstallTime;
        packageSetting.lastUpdateTime=lastUpdateTime;
      }
    }
 else     if (sharedIdStr != null) {
      userId=sharedIdStr != null ? Integer.parseInt(sharedIdStr) : 0;
      if (userId > 0) {
        packageSetting=new PendingPackage(name.intern(),realName,new File(codePathStr),new File(resourcePathStr),nativeLibraryPathStr,userId,versionCode,pkgFlags);
        packageSetting.setTimeStamp(timeStamp);
        packageSetting.firstInstallTime=firstInstallTime;
        packageSetting.lastUpdateTime=lastUpdateTime;
        mPendingPackages.add((PendingPackage)packageSetting);
        if (PackageManagerService.DEBUG_SETTINGS)         Log.i(PackageManagerService.TAG,"String_Node_Str" + name + "String_Node_Str"+ userId+ "String_Node_Str"+ packageSetting);
      }
 else {
        PackageManagerService.reportSettingsProblem(Log.WARN,"String_Node_Str" + name + "String_Node_Str"+ sharedIdStr+ "String_Node_Str"+ parser.getPositionDescription());
      }
    }
 else {
      PackageManagerService.reportSettingsProblem(Log.WARN,"String_Node_Str" + name + "String_Node_Str"+ idStr+ "String_Node_Str"+ parser.getPositionDescription());
    }
  }
 catch (  NumberFormatException e) {
    PackageManagerService.reportSettingsProblem(Log.WARN,"String_Node_Str" + name + "String_Node_Str"+ idStr+ "String_Node_Str"+ parser.getPositionDescription());
  }
  if (packageSetting != null) {
    packageSetting.uidError="String_Node_Str".equals(uidError);
    packageSetting.installerPackageName=installerPackageName;
    packageSetting.nativeLibraryPathString=nativeLibraryPathStr;
    final String enabledStr=parser.getAttributeValue(null,ATTR_ENABLED);
    if (enabledStr != null) {
      try {
        packageSetting.setEnabled(Integer.parseInt(enabledStr),0,null);
      }
 catch (      NumberFormatException e) {
        if (enabledStr.equalsIgnoreCase("String_Node_Str")) {
          packageSetting.setEnabled(COMPONENT_ENABLED_STATE_ENABLED,0,null);
        }
 else         if (enabledStr.equalsIgnoreCase("String_Node_Str")) {
          packageSetting.setEnabled(COMPONENT_ENABLED_STATE_DISABLED,0,null);
        }
 else         if (enabledStr.equalsIgnoreCase("String_Node_Str")) {
          packageSetting.setEnabled(COMPONENT_ENABLED_STATE_DEFAULT,0,null);
        }
 else {
          PackageManagerService.reportSettingsProblem(Log.WARN,"String_Node_Str" + name + "String_Node_Str"+ idStr+ "String_Node_Str"+ parser.getPositionDescription());
        }
      }
    }
 else {
      packageSetting.setEnabled(COMPONENT_ENABLED_STATE_DEFAULT,0,null);
    }
    final String installStatusStr=parser.getAttributeValue(null,"String_Node_Str");
    if (installStatusStr != null) {
      if (installStatusStr.equalsIgnoreCase("String_Node_Str")) {
        packageSetting.installStatus=PackageSettingBase.PKG_INSTALL_INCOMPLETE;
      }
 else {
        packageSetting.installStatus=PackageSettingBase.PKG_INSTALL_COMPLETE;
      }
    }
    int outerDepth=parser.getDepth();
    int type;
    while ((type=parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
      if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
        continue;
      }
      String tagName=parser.getName();
      if (tagName.equals(TAG_DISABLED_COMPONENTS)) {
        readDisabledComponentsLPw(packageSetting,parser,0);
      }
 else       if (tagName.equals(TAG_ENABLED_COMPONENTS)) {
        readEnabledComponentsLPw(packageSetting,parser,0);
      }
 else       if (tagName.equals("String_Node_Str")) {
        packageSetting.signatures.readXml(parser,mPastSignatures);
      }
 else       if (tagName.equals("String_Node_Str")) {
        readGrantedPermissionsLPw(parser,packageSetting.grantedPermissions);
        packageSetting.permissionsFixed=true;
      }
 else       if (tagName.equals("String_Node_Str")) {
        long id=Long.parseLong(parser.getAttributeValue(null,"String_Node_Str"));
        packageSetting.keySetData.addSigningKeySet(id);
        if (false)         Slog.d(TAG,"String_Node_Str" + Long.toString(id) + "String_Node_Str"+ name);
      }
 else       if (tagName.equals("String_Node_Str")) {
        long id=Long.parseLong(parser.getAttributeValue(null,"String_Node_Str"));
        String alias=parser.getAttributeValue(null,"String_Node_Str");
        packageSetting.keySetData.addDefinedKeySet(id,alias);
      }
 else {
        PackageManagerService.reportSettingsProblem(Log.WARN,"String_Node_Str" + parser.getName());
        XmlUtils.skipCurrentTag(parser);
      }
    }
  }
 else {
    XmlUtils.skipCurrentTag(parser);
  }
}