Program: 162429
Project: 162429
Buggy source:
@Override protected Pair<OpenMode,ArrayList<LayoutElementParcelable>> doInBackground(Void... p){
  HybridFile hFile=null;
  if (openmode == OpenMode.UNKNOWN) {
    hFile=new HybridFile(OpenMode.UNKNOWN,path);
    hFile.generateMode(ma.getActivity());
    openmode=hFile.getMode();
    if (hFile.isSmb()) {
      ma.smbPath=path;
    }
 else     if (android.util.Patterns.EMAIL_ADDRESS.matcher(path).matches()) {
      openmode=OpenMode.ROOT;
    }
  }
  if (isCancelled())   return null;
  ma.folder_count=0;
  ma.file_count=0;
  final ArrayList<LayoutElementParcelable> list;
switch (openmode) {
case SMB:
    if (hFile == null) {
      hFile=new HybridFile(OpenMode.SMB,path);
    }
  try {
    SmbFile[] smbFile=hFile.getSmbFile(5000).listFiles();
    list=ma.addToSmb(smbFile,path);
    openmode=OpenMode.SMB;
  }
 catch (  SmbAuthException e) {
    if (!e.getMessage().toLowerCase().contains("String_Node_Str")) {
      ma.reauthenticateSmb();
    }
    return null;
  }
catch (  SmbException|NullPointerException e) {
    e.printStackTrace();
    return null;
  }
break;
case SFTP:
HybridFile sftpHFile=new HybridFile(OpenMode.SFTP,path);
list=new ArrayList<LayoutElementParcelable>();
sftpHFile.forEachChildrenFile(c,false,file -> {
LayoutElementParcelable elem=createListParcelables(file);
if (elem != null) list.add(elem);
}
);
break;
case CUSTOM:
switch (Integer.parseInt(path)) {
case 0:
list=listImages();
break;
case 1:
list=listVideos();
break;
case 2:
list=listaudio();
break;
case 3:
list=listDocs();
break;
case 4:
list=listApks();
break;
case 5:
list=listRecent();
break;
case 6:
list=listRecentFiles();
break;
default :
throw new IllegalStateException();
}
break;
case OTG:
list=new ArrayList<>();
listOtg(path,file -> {
LayoutElementParcelable elem=createListParcelables(file);
if (elem != null) list.add(elem);
}
);
openmode=OpenMode.OTG;
break;
case DROPBOX:
case BOX:
case GDRIVE:
case ONEDRIVE:
CloudStorage cloudStorage=dataUtils.getAccount(openmode);
list=new ArrayList<>();
try {
listCloud(path,cloudStorage,openmode,file -> {
LayoutElementParcelable elem=createListParcelables(file);
if (elem != null) list.add(elem);
}
);
}
 catch (CloudPluginException e) {
e.printStackTrace();
AppConfig.toast(c,c.getResources().getString(R.string.failed_no_connection));
return new Pair<>(openmode,list);
}
break;
default :
list=new ArrayList<>();
RootHelper.getFiles(path,ma.getMainActivity().isRootExplorer(),showHiddenFiles,mode -> openmode=mode,file -> {
LayoutElementParcelable elem=createListParcelables(file);
if (elem != null) list.add(elem);
}
);
break;
}
if (list != null && !(openmode == OpenMode.CUSTOM && ((path).equals("String_Node_Str") || (path).equals("String_Node_Str")))) {
Collections.sort(list,new FileListSorter(ma.dsort,ma.sortby,ma.asc));
}
return new Pair<>(openmode,list);
}

Fixed version (ground truth):
@Override protected Pair<OpenMode,ArrayList<LayoutElementParcelable>> doInBackground(Void... p){
  HybridFile hFile=null;
  if (openmode == OpenMode.UNKNOWN) {
    hFile=new HybridFile(OpenMode.UNKNOWN,path);
    hFile.generateMode(ma.getActivity());
    openmode=hFile.getMode();
    if (hFile.isSmb()) {
      ma.smbPath=path;
    }
 else     if (android.util.Patterns.EMAIL_ADDRESS.matcher(path).matches()) {
      openmode=OpenMode.ROOT;
    }
  }
  if (isCancelled())   return null;
  ma.folder_count=0;
  ma.file_count=0;
  final ArrayList<LayoutElementParcelable> list;
switch (openmode) {
case SMB:
    if (hFile == null) {
      hFile=new HybridFile(OpenMode.SMB,path);
    }
  try {
    SmbFile[] smbFile=hFile.getSmbFile(5000).listFiles();
    list=ma.addToSmb(smbFile,path,showHiddenFiles);
    openmode=OpenMode.SMB;
  }
 catch (  SmbAuthException e) {
    if (!e.getMessage().toLowerCase().contains("String_Node_Str")) {
      ma.reauthenticateSmb();
    }
    return null;
  }
catch (  SmbException|NullPointerException e) {
    e.printStackTrace();
    return null;
  }
break;
case SFTP:
HybridFile sftpHFile=new HybridFile(OpenMode.SFTP,path);
list=new ArrayList<LayoutElementParcelable>();
sftpHFile.forEachChildrenFile(c,false,file -> {
LayoutElementParcelable elem=createListParcelables(file);
if (elem != null) list.add(elem);
}
);
break;
case CUSTOM:
switch (Integer.parseInt(path)) {
case 0:
list=listImages();
break;
case 1:
list=listVideos();
break;
case 2:
list=listaudio();
break;
case 3:
list=listDocs();
break;
case 4:
list=listApks();
break;
case 5:
list=listRecent();
break;
case 6:
list=listRecentFiles();
break;
default :
throw new IllegalStateException();
}
break;
case OTG:
list=new ArrayList<>();
listOtg(path,file -> {
LayoutElementParcelable elem=createListParcelables(file);
if (elem != null) list.add(elem);
}
);
openmode=OpenMode.OTG;
break;
case DROPBOX:
case BOX:
case GDRIVE:
case ONEDRIVE:
CloudStorage cloudStorage=dataUtils.getAccount(openmode);
list=new ArrayList<>();
try {
listCloud(path,cloudStorage,openmode,file -> {
LayoutElementParcelable elem=createListParcelables(file);
if (elem != null) list.add(elem);
}
);
}
 catch (CloudPluginException e) {
e.printStackTrace();
AppConfig.toast(c,c.getResources().getString(R.string.failed_no_connection));
return new Pair<>(openmode,list);
}
break;
default :
list=new ArrayList<>();
RootHelper.getFiles(path,ma.getMainActivity().isRootExplorer(),showHiddenFiles,mode -> openmode=mode,file -> {
LayoutElementParcelable elem=createListParcelables(file);
if (elem != null) list.add(elem);
}
);
break;
}
if (list != null && !(openmode == OpenMode.CUSTOM && ((path).equals("String_Node_Str") || (path).equals("String_Node_Str")))) {
Collections.sort(list,new FileListSorter(ma.dsort,ma.sortby,ma.asc));
}
return new Pair<>(openmode,list);
}