Program: 41646
Project: 41646
Buggy source:
private void loadMediaPackages(HashMap<SdInstallArgs,String> processCids,int uidArr[],HashSet<String> removeCids){
  ArrayList<String> pkgList=new ArrayList<String>();
  Set<SdInstallArgs> keys=processCids.keySet();
  boolean doGc=false;
  for (  SdInstallArgs args : keys) {
    String codePath=processCids.get(args);
    if (DEBUG_SD_INSTALL)     Log.i(TAG,"String_Node_Str" + args.cid);
    int retCode=PackageManager.INSTALL_FAILED_CONTAINER_ERROR;
    try {
      if (args.doPreInstall(PackageManager.INSTALL_SUCCEEDED) != PackageManager.INSTALL_SUCCEEDED) {
        Slog.e(TAG,"String_Node_Str" + args.cid + "String_Node_Str");
        continue;
      }
      if (codePath == null || !codePath.equals(args.getCodePath())) {
        Slog.e(TAG,"String_Node_Str" + args.cid + "String_Node_Str"+ args.getCodePath()+ "String_Node_Str"+ codePath);
        continue;
      }
      int parseFlags=PackageParser.PARSE_ON_SDCARD | mDefParseFlags;
      doGc=true;
synchronized (mInstallLock) {
        final PackageParser.Package pkg=scanPackageLI(new File(codePath),parseFlags,0);
        if (pkg != null) {
synchronized (mPackages) {
            retCode=PackageManager.INSTALL_SUCCEEDED;
            pkgList.add(pkg.packageName);
            args.doPostInstall(PackageManager.INSTALL_SUCCEEDED);
          }
        }
 else {
          Slog.i(TAG,"String_Node_Str" + codePath + "String_Node_Str");
        }
      }
    }
  finally {
      if (retCode != PackageManager.INSTALL_SUCCEEDED) {
        removeCids.add(args.cid);
      }
    }
  }
synchronized (mPackages) {
    final boolean regrantPermissions=mSettings.mExternalSdkPlatform != mSdkVersion;
    if (regrantPermissions)     Slog.i(TAG,"String_Node_Str" + mSettings.mExternalSdkPlatform + "String_Node_Str"+ mSdkVersion+ "String_Node_Str");
    mSettings.mExternalSdkPlatform=mSdkVersion;
    updatePermissionsLP(null,null,true,regrantPermissions);
    mSettings.writeLP();
  }
  if (pkgList.size() > 0) {
    sendResourcesChangedBroadcast(true,pkgList,uidArr,null);
  }
  if (doGc) {
    Runtime.getRuntime().gc();
  }
  if (removeCids != null) {
    for (    String cid : removeCids) {
      Log.w(TAG,"String_Node_Str" + cid + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
private void loadMediaPackages(HashMap<SdInstallArgs,String> processCids,int uidArr[],HashSet<String> removeCids){
  ArrayList<String> pkgList=new ArrayList<String>();
  Set<SdInstallArgs> keys=processCids.keySet();
  boolean doGc=false;
  for (  SdInstallArgs args : keys) {
    String codePath=processCids.get(args);
    if (DEBUG_SD_INSTALL)     Log.i(TAG,"String_Node_Str" + args.cid);
    int retCode=PackageManager.INSTALL_FAILED_CONTAINER_ERROR;
    try {
      if (args.doPreInstall(PackageManager.INSTALL_SUCCEEDED) != PackageManager.INSTALL_SUCCEEDED) {
        Slog.e(TAG,"String_Node_Str" + args.cid + "String_Node_Str");
        continue;
      }
      if (codePath == null || !codePath.equals(args.getCodePath())) {
        Slog.e(TAG,"String_Node_Str" + args.cid + "String_Node_Str"+ args.getCodePath()+ "String_Node_Str"+ codePath);
        continue;
      }
      int parseFlags=PackageParser.PARSE_ON_SDCARD | mDefParseFlags;
      doGc=true;
synchronized (mInstallLock) {
        final PackageParser.Package pkg=scanPackageLI(new File(codePath),parseFlags,0);
        if (pkg != null) {
synchronized (mPackages) {
            retCode=PackageManager.INSTALL_SUCCEEDED;
            pkgList.add(pkg.packageName);
            args.doPostInstall(PackageManager.INSTALL_SUCCEEDED);
          }
        }
 else {
          Slog.i(TAG,"String_Node_Str" + codePath + "String_Node_Str");
        }
      }
    }
  finally {
      if (retCode != PackageManager.INSTALL_SUCCEEDED) {
        removeCids.add(args.cid);
      }
    }
  }
synchronized (mPackages) {
    final boolean regrantPermissions=mSettings.mExternalSdkPlatform != mSdkVersion;
    if (regrantPermissions)     Slog.i(TAG,"String_Node_Str" + mSettings.mExternalSdkPlatform + "String_Node_Str"+ mSdkVersion+ "String_Node_Str");
    mSettings.mExternalSdkPlatform=mSdkVersion;
    updatePermissionsLP(null,null,true,regrantPermissions,regrantPermissions);
    mSettings.writeLP();
  }
  if (pkgList.size() > 0) {
    sendResourcesChangedBroadcast(true,pkgList,uidArr,null);
  }
  if (doGc) {
    Runtime.getRuntime().gc();
  }
  if (removeCids != null) {
    for (    String cid : removeCids) {
      Log.w(TAG,"String_Node_Str" + cid + "String_Node_Str");
    }
  }
}