Program: 1505
Project: 1505
Buggy source:
private boolean parseApplication(Package owner,Resources res,XmlPullParser parser,AttributeSet attrs,int flags,String[] outError) throws XmlPullParserException, IOException {
  final ApplicationInfo ai=owner.applicationInfo;
  final String pkgName=owner.applicationInfo.packageName;
  TypedArray sa=res.obtainAttributes(attrs,com.android.internal.R.styleable.AndroidManifestApplication);
  String name=sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestApplication_name,0);
  if (name != null) {
    ai.className=buildClassName(pkgName,name,outError);
    if (ai.className == null) {
      sa.recycle();
      mParseError=PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
      return false;
    }
  }
  String manageSpaceActivity=sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestApplication_manageSpaceActivity,0);
  if (manageSpaceActivity != null) {
    ai.manageSpaceActivityName=buildClassName(pkgName,manageSpaceActivity,outError);
  }
  boolean allowBackup=sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_allowBackup,true);
  if (allowBackup) {
    ai.flags|=ApplicationInfo.FLAG_ALLOW_BACKUP;
    String backupAgent=sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestApplication_backupAgent,0);
    if (backupAgent != null) {
      ai.backupAgentName=buildClassName(pkgName,backupAgent,outError);
      if (DEBUG_BACKUP) {
        Slog.v(TAG,"String_Node_Str" + ai.backupAgentName + "String_Node_Str"+ pkgName+ "String_Node_Str"+ backupAgent);
      }
      if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_killAfterRestore,true)) {
        ai.flags|=ApplicationInfo.FLAG_KILL_AFTER_RESTORE;
      }
      if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_restoreAnyVersion,false)) {
        ai.flags|=ApplicationInfo.FLAG_RESTORE_ANY_VERSION;
      }
    }
  }
  TypedValue v=sa.peekValue(com.android.internal.R.styleable.AndroidManifestApplication_label);
  if (v != null && (ai.labelRes=v.resourceId) == 0) {
    ai.nonLocalizedLabel=v.coerceToString();
  }
  ai.icon=sa.getResourceId(com.android.internal.R.styleable.AndroidManifestApplication_icon,0);
  ai.logo=sa.getResourceId(com.android.internal.R.styleable.AndroidManifestApplication_logo,0);
  ai.theme=sa.getResourceId(com.android.internal.R.styleable.AndroidManifestApplication_theme,0);
  ai.descriptionRes=sa.getResourceId(com.android.internal.R.styleable.AndroidManifestApplication_description,0);
  if ((flags & PARSE_IS_SYSTEM) != 0) {
    if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_persistent,false)) {
      ai.flags|=ApplicationInfo.FLAG_PERSISTENT;
    }
  }
  if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_requiredForAllUsers,false)) {
    owner.mRequiredForAllUsers=true;
  }
  String restrictedAccountType=sa.getString(com.android.internal.R.styleable.AndroidManifestApplication_restrictedAccountType);
  if (restrictedAccountType != null && restrictedAccountType.length() > 0) {
    owner.mRestrictedAccountType=restrictedAccountType;
  }
  String requiredAccountType=sa.getString(com.android.internal.R.styleable.AndroidManifestApplication_requiredAccountType);
  if (requiredAccountType != null && requiredAccountType.length() > 0) {
    owner.mRequiredAccountType=requiredAccountType;
  }
  if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_debuggable,false)) {
    ai.flags|=ApplicationInfo.FLAG_DEBUGGABLE;
  }
  if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_vmSafeMode,false)) {
    ai.flags|=ApplicationInfo.FLAG_VM_SAFE_MODE;
  }
  boolean hardwareAccelerated=sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_hardwareAccelerated,owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.ICE_CREAM_SANDWICH);
  if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_hasCode,true)) {
    ai.flags|=ApplicationInfo.FLAG_HAS_CODE;
  }
  if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_allowTaskReparenting,false)) {
    ai.flags|=ApplicationInfo.FLAG_ALLOW_TASK_REPARENTING;
  }
  if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_allowClearUserData,true)) {
    ai.flags|=ApplicationInfo.FLAG_ALLOW_CLEAR_USER_DATA;
  }
  if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_testOnly,false)) {
    ai.flags|=ApplicationInfo.FLAG_TEST_ONLY;
  }
  if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_largeHeap,false)) {
    ai.flags|=ApplicationInfo.FLAG_LARGE_HEAP;
  }
  if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_supportsRtl,false)) {
    ai.flags|=ApplicationInfo.FLAG_SUPPORTS_RTL;
  }
  String str;
  str=sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestApplication_permission,0);
  ai.permission=(str != null && str.length() > 0) ? str.intern() : null;
  if (owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.FROYO) {
    str=sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestApplication_taskAffinity,0);
  }
 else {
    str=sa.getNonResourceString(com.android.internal.R.styleable.AndroidManifestApplication_taskAffinity);
  }
  ai.taskAffinity=buildTaskAffinityName(ai.packageName,ai.packageName,str,outError);
  if (outError[0] == null) {
    CharSequence pname;
    if (owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.FROYO) {
      pname=sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestApplication_process,0);
    }
 else {
      pname=sa.getNonResourceString(com.android.internal.R.styleable.AndroidManifestApplication_process);
    }
    ai.processName=buildProcessName(ai.packageName,null,pname,flags,mSeparateProcesses,outError);
    ai.enabled=sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_enabled,true);
    if (false) {
      if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_cantSaveState,false)) {
        ai.flags|=ApplicationInfo.FLAG_CANT_SAVE_STATE;
        if (ai.processName != null && ai.processName != ai.packageName) {
          outError[0]="String_Node_Str";
        }
      }
    }
  }
  ai.uiOptions=sa.getInt(com.android.internal.R.styleable.AndroidManifestApplication_uiOptions,0);
  sa.recycle();
  if (outError[0] != null) {
    mParseError=PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
    return false;
  }
  final int innerDepth=parser.getDepth();
  int type;
  while ((type=parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > innerDepth)) {
    if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
      continue;
    }
    String tagName=parser.getName();
    if (tagName.equals("String_Node_Str")) {
      Activity a=parseActivity(owner,res,parser,attrs,flags,outError,false,hardwareAccelerated);
      if (a == null) {
        mParseError=PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
        return false;
      }
      owner.activities.add(a);
    }
 else     if (tagName.equals("String_Node_Str")) {
      Activity a=parseActivity(owner,res,parser,attrs,flags,outError,true,false);
      if (a == null) {
        mParseError=PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
        return false;
      }
      owner.receivers.add(a);
    }
 else     if (tagName.equals("String_Node_Str")) {
      Service s=parseService(owner,res,parser,attrs,flags,outError);
      if (s == null) {
        mParseError=PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
        return false;
      }
      owner.services.add(s);
    }
 else     if (tagName.equals("String_Node_Str")) {
      Provider p=parseProvider(owner,res,parser,attrs,flags,outError);
      if (p == null) {
        mParseError=PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
        return false;
      }
      owner.providers.add(p);
    }
 else     if (tagName.equals("String_Node_Str")) {
      Activity a=parseActivityAlias(owner,res,parser,attrs,flags,outError);
      if (a == null) {
        mParseError=PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
        return false;
      }
      owner.activities.add(a);
    }
 else     if (parser.getName().equals("String_Node_Str")) {
      if ((owner.mAppMetaData=parseMetaData(res,parser,attrs,owner.mAppMetaData,outError)) == null) {
        mParseError=PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
        return false;
      }
    }
 else     if (tagName.equals("String_Node_Str")) {
      sa=res.obtainAttributes(attrs,com.android.internal.R.styleable.AndroidManifestLibrary);
      String lname=sa.getNonResourceString(com.android.internal.R.styleable.AndroidManifestLibrary_name);
      sa.recycle();
      if (lname != null) {
        if (owner.libraryNames == null) {
          owner.libraryNames=new ArrayList<String>();
        }
        if (!owner.libraryNames.contains(lname)) {
          owner.libraryNames.add(lname.intern());
        }
      }
      XmlUtils.skipCurrentTag(parser);
    }
 else     if (tagName.equals("String_Node_Str")) {
      sa=res.obtainAttributes(attrs,com.android.internal.R.styleable.AndroidManifestUsesLibrary);
      String lname=sa.getNonResourceString(com.android.internal.R.styleable.AndroidManifestUsesLibrary_name);
      boolean req=sa.getBoolean(com.android.internal.R.styleable.AndroidManifestUsesLibrary_required,true);
      sa.recycle();
      if (lname != null) {
        if (req) {
          if (owner.usesLibraries == null) {
            owner.usesLibraries=new ArrayList<String>();
          }
          if (!owner.usesLibraries.contains(lname)) {
            owner.usesLibraries.add(lname.intern());
          }
        }
 else {
          if (owner.usesOptionalLibraries == null) {
            owner.usesOptionalLibraries=new ArrayList<String>();
          }
          if (!owner.usesOptionalLibraries.contains(lname)) {
            owner.usesOptionalLibraries.add(lname.intern());
          }
        }
      }
      XmlUtils.skipCurrentTag(parser);
    }
 else     if (tagName.equals("String_Node_Str")) {
      XmlUtils.skipCurrentTag(parser);
    }
 else {
      if (!RIGID_PARSER) {
        Slog.w(TAG,"String_Node_Str" + tagName + "String_Node_Str"+ mArchiveSourcePath+ "String_Node_Str"+ parser.getPositionDescription());
        XmlUtils.skipCurrentTag(parser);
        continue;
      }
 else {
        outError[0]="String_Node_Str" + tagName;
        mParseError=PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
        return false;
      }
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean parseApplication(Package owner,Resources res,XmlPullParser parser,AttributeSet attrs,int flags,String[] outError) throws XmlPullParserException, IOException {
  final ApplicationInfo ai=owner.applicationInfo;
  final String pkgName=owner.applicationInfo.packageName;
  TypedArray sa=res.obtainAttributes(attrs,com.android.internal.R.styleable.AndroidManifestApplication);
  String name=sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestApplication_name,0);
  if (name != null) {
    ai.className=buildClassName(pkgName,name,outError);
    if (ai.className == null) {
      sa.recycle();
      mParseError=PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
      return false;
    }
  }
  String manageSpaceActivity=sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestApplication_manageSpaceActivity,Configuration.NATIVE_CONFIG_VERSION);
  if (manageSpaceActivity != null) {
    ai.manageSpaceActivityName=buildClassName(pkgName,manageSpaceActivity,outError);
  }
  boolean allowBackup=sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_allowBackup,true);
  if (allowBackup) {
    ai.flags|=ApplicationInfo.FLAG_ALLOW_BACKUP;
    String backupAgent=sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestApplication_backupAgent,Configuration.NATIVE_CONFIG_VERSION);
    if (backupAgent != null) {
      ai.backupAgentName=buildClassName(pkgName,backupAgent,outError);
      if (DEBUG_BACKUP) {
        Slog.v(TAG,"String_Node_Str" + ai.backupAgentName + "String_Node_Str"+ pkgName+ "String_Node_Str"+ backupAgent);
      }
      if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_killAfterRestore,true)) {
        ai.flags|=ApplicationInfo.FLAG_KILL_AFTER_RESTORE;
      }
      if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_restoreAnyVersion,false)) {
        ai.flags|=ApplicationInfo.FLAG_RESTORE_ANY_VERSION;
      }
    }
  }
  TypedValue v=sa.peekValue(com.android.internal.R.styleable.AndroidManifestApplication_label);
  if (v != null && (ai.labelRes=v.resourceId) == 0) {
    ai.nonLocalizedLabel=v.coerceToString();
  }
  ai.icon=sa.getResourceId(com.android.internal.R.styleable.AndroidManifestApplication_icon,0);
  ai.logo=sa.getResourceId(com.android.internal.R.styleable.AndroidManifestApplication_logo,0);
  ai.theme=sa.getResourceId(com.android.internal.R.styleable.AndroidManifestApplication_theme,0);
  ai.descriptionRes=sa.getResourceId(com.android.internal.R.styleable.AndroidManifestApplication_description,0);
  if ((flags & PARSE_IS_SYSTEM) != 0) {
    if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_persistent,false)) {
      ai.flags|=ApplicationInfo.FLAG_PERSISTENT;
    }
  }
  if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_requiredForAllUsers,false)) {
    owner.mRequiredForAllUsers=true;
  }
  String restrictedAccountType=sa.getString(com.android.internal.R.styleable.AndroidManifestApplication_restrictedAccountType);
  if (restrictedAccountType != null && restrictedAccountType.length() > 0) {
    owner.mRestrictedAccountType=restrictedAccountType;
  }
  String requiredAccountType=sa.getString(com.android.internal.R.styleable.AndroidManifestApplication_requiredAccountType);
  if (requiredAccountType != null && requiredAccountType.length() > 0) {
    owner.mRequiredAccountType=requiredAccountType;
  }
  if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_debuggable,false)) {
    ai.flags|=ApplicationInfo.FLAG_DEBUGGABLE;
  }
  if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_vmSafeMode,false)) {
    ai.flags|=ApplicationInfo.FLAG_VM_SAFE_MODE;
  }
  boolean hardwareAccelerated=sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_hardwareAccelerated,owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.ICE_CREAM_SANDWICH);
  if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_hasCode,true)) {
    ai.flags|=ApplicationInfo.FLAG_HAS_CODE;
  }
  if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_allowTaskReparenting,false)) {
    ai.flags|=ApplicationInfo.FLAG_ALLOW_TASK_REPARENTING;
  }
  if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_allowClearUserData,true)) {
    ai.flags|=ApplicationInfo.FLAG_ALLOW_CLEAR_USER_DATA;
  }
  if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_testOnly,false)) {
    ai.flags|=ApplicationInfo.FLAG_TEST_ONLY;
  }
  if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_largeHeap,false)) {
    ai.flags|=ApplicationInfo.FLAG_LARGE_HEAP;
  }
  if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_supportsRtl,false)) {
    ai.flags|=ApplicationInfo.FLAG_SUPPORTS_RTL;
  }
  String str;
  str=sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestApplication_permission,0);
  ai.permission=(str != null && str.length() > 0) ? str.intern() : null;
  if (owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.FROYO) {
    str=sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestApplication_taskAffinity,Configuration.NATIVE_CONFIG_VERSION);
  }
 else {
    str=sa.getNonResourceString(com.android.internal.R.styleable.AndroidManifestApplication_taskAffinity);
  }
  ai.taskAffinity=buildTaskAffinityName(ai.packageName,ai.packageName,str,outError);
  if (outError[0] == null) {
    CharSequence pname;
    if (owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.FROYO) {
      pname=sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestApplication_process,Configuration.NATIVE_CONFIG_VERSION);
    }
 else {
      pname=sa.getNonResourceString(com.android.internal.R.styleable.AndroidManifestApplication_process);
    }
    ai.processName=buildProcessName(ai.packageName,null,pname,flags,mSeparateProcesses,outError);
    ai.enabled=sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_enabled,true);
    if (false) {
      if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_cantSaveState,false)) {
        ai.flags|=ApplicationInfo.FLAG_CANT_SAVE_STATE;
        if (ai.processName != null && ai.processName != ai.packageName) {
          outError[0]="String_Node_Str";
        }
      }
    }
  }
  ai.uiOptions=sa.getInt(com.android.internal.R.styleable.AndroidManifestApplication_uiOptions,0);
  sa.recycle();
  if (outError[0] != null) {
    mParseError=PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
    return false;
  }
  final int innerDepth=parser.getDepth();
  int type;
  while ((type=parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > innerDepth)) {
    if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
      continue;
    }
    String tagName=parser.getName();
    if (tagName.equals("String_Node_Str")) {
      Activity a=parseActivity(owner,res,parser,attrs,flags,outError,false,hardwareAccelerated);
      if (a == null) {
        mParseError=PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
        return false;
      }
      owner.activities.add(a);
    }
 else     if (tagName.equals("String_Node_Str")) {
      Activity a=parseActivity(owner,res,parser,attrs,flags,outError,true,false);
      if (a == null) {
        mParseError=PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
        return false;
      }
      owner.receivers.add(a);
    }
 else     if (tagName.equals("String_Node_Str")) {
      Service s=parseService(owner,res,parser,attrs,flags,outError);
      if (s == null) {
        mParseError=PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
        return false;
      }
      owner.services.add(s);
    }
 else     if (tagName.equals("String_Node_Str")) {
      Provider p=parseProvider(owner,res,parser,attrs,flags,outError);
      if (p == null) {
        mParseError=PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
        return false;
      }
      owner.providers.add(p);
    }
 else     if (tagName.equals("String_Node_Str")) {
      Activity a=parseActivityAlias(owner,res,parser,attrs,flags,outError);
      if (a == null) {
        mParseError=PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
        return false;
      }
      owner.activities.add(a);
    }
 else     if (parser.getName().equals("String_Node_Str")) {
      if ((owner.mAppMetaData=parseMetaData(res,parser,attrs,owner.mAppMetaData,outError)) == null) {
        mParseError=PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
        return false;
      }
    }
 else     if (tagName.equals("String_Node_Str")) {
      sa=res.obtainAttributes(attrs,com.android.internal.R.styleable.AndroidManifestLibrary);
      String lname=sa.getNonResourceString(com.android.internal.R.styleable.AndroidManifestLibrary_name);
      sa.recycle();
      if (lname != null) {
        if (owner.libraryNames == null) {
          owner.libraryNames=new ArrayList<String>();
        }
        if (!owner.libraryNames.contains(lname)) {
          owner.libraryNames.add(lname.intern());
        }
      }
      XmlUtils.skipCurrentTag(parser);
    }
 else     if (tagName.equals("String_Node_Str")) {
      sa=res.obtainAttributes(attrs,com.android.internal.R.styleable.AndroidManifestUsesLibrary);
      String lname=sa.getNonResourceString(com.android.internal.R.styleable.AndroidManifestUsesLibrary_name);
      boolean req=sa.getBoolean(com.android.internal.R.styleable.AndroidManifestUsesLibrary_required,true);
      sa.recycle();
      if (lname != null) {
        if (req) {
          if (owner.usesLibraries == null) {
            owner.usesLibraries=new ArrayList<String>();
          }
          if (!owner.usesLibraries.contains(lname)) {
            owner.usesLibraries.add(lname.intern());
          }
        }
 else {
          if (owner.usesOptionalLibraries == null) {
            owner.usesOptionalLibraries=new ArrayList<String>();
          }
          if (!owner.usesOptionalLibraries.contains(lname)) {
            owner.usesOptionalLibraries.add(lname.intern());
          }
        }
      }
      XmlUtils.skipCurrentTag(parser);
    }
 else     if (tagName.equals("String_Node_Str")) {
      XmlUtils.skipCurrentTag(parser);
    }
 else {
      if (!RIGID_PARSER) {
        Slog.w(TAG,"String_Node_Str" + tagName + "String_Node_Str"+ mArchiveSourcePath+ "String_Node_Str"+ parser.getPositionDescription());
        XmlUtils.skipCurrentTag(parser);
        continue;
      }
 else {
        outError[0]="String_Node_Str" + tagName;
        mParseError=PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
        return false;
      }
    }
  }
  return true;
}