Program: 181670
Project: 181670
Buggy source:
private void updateExternalMediaStatusInner(boolean mediaStatus,boolean reportStatus){
  int uidArr[]=null;
  HashSet<String> removeCids=new HashSet<String>();
  HashMap<SdInstallArgs,String> processCids=new HashMap<SdInstallArgs,String>();
  final String list[]=PackageHelper.getSecureContainerList();
  if (list == null || list.length == 0) {
    Log.i(TAG,"String_Node_Str");
  }
 else {
    int uidList[]=new int[list.length];
    int num=0;
synchronized (mPackages) {
      for (      String cid : list) {
        SdInstallArgs args=new SdInstallArgs(cid);
        if (DEBUG_SD_INSTALL)         Log.i(TAG,"String_Node_Str" + cid);
        String pkgName=args.getPackageName();
        if (pkgName == null) {
          if (DEBUG_SD_INSTALL)           Log.i(TAG,"String_Node_Str" + cid + "String_Node_Str");
          removeCids.add(cid);
          continue;
        }
        if (DEBUG_SD_INSTALL)         Log.i(TAG,"String_Node_Str" + pkgName);
        PackageSetting ps=mSettings.mPackages.get(pkgName);
        if (ps != null && ps.codePathString != null && (ps.pkgFlags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0) {
          if (DEBUG_SD_INSTALL)           Log.i(TAG,"String_Node_Str" + cid + "String_Node_Str"+ pkgName+ "String_Node_Str"+ ps.codePathString);
          processCids.put(args,ps.codePathString);
          int uid=ps.userId;
          if (uid != -1) {
            uidList[num++]=uid;
          }
        }
 else {
          if (DEBUG_SD_INSTALL)           Log.i(TAG,"String_Node_Str" + cid + "String_Node_Str");
          removeCids.add(cid);
        }
      }
    }
    if (num > 0) {
      Arrays.sort(uidList,0,num);
      uidArr=new int[num];
      uidArr[0]=uidList[0];
      int di=0;
      for (int i=1; i < num; i++) {
        if (uidList[i - 1] != uidList[i]) {
          uidArr[di++]=uidList[i];
        }
      }
    }
  }
  if (mediaStatus) {
    if (DEBUG_SD_INSTALL)     Log.i(TAG,"String_Node_Str");
    loadMediaPackages(processCids,uidArr,removeCids);
    startCleaningPackages();
  }
 else {
    if (DEBUG_SD_INSTALL)     Log.i(TAG,"String_Node_Str");
    unloadMediaPackages(processCids,uidArr,reportStatus);
  }
}

Fixed version (ground truth):
private void updateExternalMediaStatusInner(boolean mediaStatus,boolean reportStatus){
  int uidArr[]=null;
  HashSet<String> removeCids=new HashSet<String>();
  HashMap<SdInstallArgs,String> processCids=new HashMap<SdInstallArgs,String>();
  final String list[]=PackageHelper.getSecureContainerList();
  if (list == null || list.length == 0) {
    Log.i(TAG,"String_Node_Str");
  }
 else {
    int uidList[]=new int[list.length];
    int num=0;
synchronized (mPackages) {
      for (      String cid : list) {
        SdInstallArgs args=new SdInstallArgs(cid);
        if (DEBUG_SD_INSTALL)         Log.i(TAG,"String_Node_Str" + cid);
        String pkgName=args.getPackageName();
        if (pkgName == null) {
          if (DEBUG_SD_INSTALL)           Log.i(TAG,"String_Node_Str" + cid + "String_Node_Str");
          removeCids.add(cid);
          continue;
        }
        if (DEBUG_SD_INSTALL)         Log.i(TAG,"String_Node_Str" + pkgName);
        PackageSetting ps=mSettings.mPackages.get(pkgName);
        if (ps != null && ps.codePathString != null) {
          if (DEBUG_SD_INSTALL)           Log.i(TAG,"String_Node_Str" + cid + "String_Node_Str"+ pkgName+ "String_Node_Str"+ ps.codePathString);
          processCids.put(args,ps.codePathString);
          int uid=ps.userId;
          if (uid != -1) {
            uidList[num++]=uid;
          }
        }
 else {
          if (DEBUG_SD_INSTALL)           Log.i(TAG,"String_Node_Str" + cid + "String_Node_Str");
          removeCids.add(cid);
        }
      }
    }
    if (num > 0) {
      Arrays.sort(uidList,0,num);
      uidArr=new int[num];
      uidArr[0]=uidList[0];
      int di=0;
      for (int i=1; i < num; i++) {
        if (uidList[i - 1] != uidList[i]) {
          uidArr[di++]=uidList[i];
        }
      }
    }
  }
  if (mediaStatus) {
    if (DEBUG_SD_INSTALL)     Log.i(TAG,"String_Node_Str");
    loadMediaPackages(processCids,uidArr,removeCids);
    startCleaningPackages();
  }
 else {
    if (DEBUG_SD_INSTALL)     Log.i(TAG,"String_Node_Str");
    unloadMediaPackages(processCids,uidArr,reportStatus);
  }
}