Program: 22260
Project: 22260
Buggy source:
private void updatePermissionsLP(String changingPkg,PackageParser.Package pkgInfo,boolean grantPermissions,boolean replace){
  Iterator<BasePermission> it=mSettings.mPermissionTrees.values().iterator();
  while (it.hasNext()) {
    BasePermission bp=it.next();
    if (bp.packageSetting == null) {
      bp.packageSetting=mSettings.mPackages.get(bp.sourcePackage);
    }
    if (bp.packageSetting == null) {
      Slog.w(TAG,"String_Node_Str" + bp.name + "String_Node_Str"+ bp.sourcePackage);
      it.remove();
    }
 else     if (changingPkg != null && changingPkg.equals(bp.sourcePackage)) {
      if (pkgInfo == null || !hasPermission(pkgInfo,bp.name)) {
        Slog.i(TAG,"String_Node_Str" + bp.name + "String_Node_Str"+ bp.sourcePackage);
        grantPermissions=true;
        it.remove();
      }
    }
  }
  it=mSettings.mPermissions.values().iterator();
  while (it.hasNext()) {
    BasePermission bp=it.next();
    if (bp.type == BasePermission.TYPE_DYNAMIC) {
      if (DEBUG_SETTINGS)       Log.v(TAG,"String_Node_Str" + bp.name + "String_Node_Str"+ bp.sourcePackage+ "String_Node_Str"+ bp.pendingInfo);
      if (bp.packageSetting == null && bp.pendingInfo != null) {
        BasePermission tree=findPermissionTreeLP(bp.name);
        if (tree != null) {
          bp.packageSetting=tree.packageSetting;
          bp.perm=new PackageParser.Permission(tree.perm.owner,new PermissionInfo(bp.pendingInfo));
          bp.perm.info.packageName=tree.perm.info.packageName;
          bp.perm.info.name=bp.name;
          bp.uid=tree.uid;
        }
      }
    }
    if (bp.packageSetting == null) {
      bp.packageSetting=mSettings.mPackages.get(bp.sourcePackage);
    }
    if (bp.packageSetting == null) {
      Slog.w(TAG,"String_Node_Str" + bp.name + "String_Node_Str"+ bp.sourcePackage);
      it.remove();
    }
 else     if (changingPkg != null && changingPkg.equals(bp.sourcePackage)) {
      if (pkgInfo == null || !hasPermission(pkgInfo,bp.name)) {
        Slog.i(TAG,"String_Node_Str" + bp.name + "String_Node_Str"+ bp.sourcePackage);
        grantPermissions=true;
        it.remove();
      }
    }
  }
  if (grantPermissions) {
    for (    PackageParser.Package pkg : mPackages.values()) {
      if (pkg != pkgInfo) {
        grantPermissionsLP(pkg,false);
      }
    }
  }
  if (pkgInfo != null) {
    grantPermissionsLP(pkgInfo,replace);
  }
}

Fixed version (ground truth):
private void updatePermissionsLP(String changingPkg,PackageParser.Package pkgInfo,boolean grantPermissions,boolean replace,boolean replaceAll){
  Iterator<BasePermission> it=mSettings.mPermissionTrees.values().iterator();
  while (it.hasNext()) {
    BasePermission bp=it.next();
    if (bp.packageSetting == null) {
      bp.packageSetting=mSettings.mPackages.get(bp.sourcePackage);
    }
    if (bp.packageSetting == null) {
      Slog.w(TAG,"String_Node_Str" + bp.name + "String_Node_Str"+ bp.sourcePackage);
      it.remove();
    }
 else     if (changingPkg != null && changingPkg.equals(bp.sourcePackage)) {
      if (pkgInfo == null || !hasPermission(pkgInfo,bp.name)) {
        Slog.i(TAG,"String_Node_Str" + bp.name + "String_Node_Str"+ bp.sourcePackage);
        grantPermissions=true;
        it.remove();
      }
    }
  }
  it=mSettings.mPermissions.values().iterator();
  while (it.hasNext()) {
    BasePermission bp=it.next();
    if (bp.type == BasePermission.TYPE_DYNAMIC) {
      if (DEBUG_SETTINGS)       Log.v(TAG,"String_Node_Str" + bp.name + "String_Node_Str"+ bp.sourcePackage+ "String_Node_Str"+ bp.pendingInfo);
      if (bp.packageSetting == null && bp.pendingInfo != null) {
        BasePermission tree=findPermissionTreeLP(bp.name);
        if (tree != null) {
          bp.packageSetting=tree.packageSetting;
          bp.perm=new PackageParser.Permission(tree.perm.owner,new PermissionInfo(bp.pendingInfo));
          bp.perm.info.packageName=tree.perm.info.packageName;
          bp.perm.info.name=bp.name;
          bp.uid=tree.uid;
        }
      }
    }
    if (bp.packageSetting == null) {
      bp.packageSetting=mSettings.mPackages.get(bp.sourcePackage);
    }
    if (bp.packageSetting == null) {
      Slog.w(TAG,"String_Node_Str" + bp.name + "String_Node_Str"+ bp.sourcePackage);
      it.remove();
    }
 else     if (changingPkg != null && changingPkg.equals(bp.sourcePackage)) {
      if (pkgInfo == null || !hasPermission(pkgInfo,bp.name)) {
        Slog.i(TAG,"String_Node_Str" + bp.name + "String_Node_Str"+ bp.sourcePackage);
        grantPermissions=true;
        it.remove();
      }
    }
  }
  if (grantPermissions) {
    for (    PackageParser.Package pkg : mPackages.values()) {
      if (pkg != pkgInfo) {
        grantPermissionsLP(pkg,replaceAll);
      }
    }
  }
  if (pkgInfo != null) {
    grantPermissionsLP(pkgInfo,replace);
  }
}