Program: 47212
Project: 47212
Buggy source:
/** 
 * Extracts embedded subtitles from video to file in SSA/ASS format, converts external SRT subtitles file to SSA/ASS format and applies fontconfig setting to that converted file and applies timeseeking when required.
 * @param dlna DLNAResource
 * @param media DLNAMediaInfo
 * @param params Output parameters
 * @param configuration
 * @return Converted subtitle file
 * @throws IOException
 */
public static File getSubtitles(DLNAResource dlna,DLNAMediaInfo media,OutputParams params,PmsConfiguration configuration,SubtitleType subtitleType) throws IOException {
  if (media == null || params.sid.getId() == -1 || !params.sid.getType().isText()) {
    return null;
  }
  String dir=configuration.getDataFile(SUB_DIR);
  File subsPath=new File(dir);
  if (!subsPath.exists()) {
    subsPath.mkdirs();
  }
  boolean applyFontConfig=configuration.isFFmpegFontConfig();
  boolean isEmbeddedSource=params.sid.getId() < 100;
  boolean is3D=media.is3d() && !media.stereoscopyIsAnaglyph();
  String filename=isEmbeddedSource ? dlna.getSystemName() : params.sid.getExternalFile().getAbsolutePath();
  String basename;
  long modId=new File(filename).lastModified();
  if (modId != 0) {
    basename=FilenameUtils.getBaseName(filename);
  }
 else {
    basename=dlna.getName().replaceAll("String_Node_Str","String_Node_Str").trim();
    modId=filename.hashCode();
  }
  File convertedSubs;
  if (applyFontConfig || isEmbeddedSource || is3D|| params.sid.getType() != subtitleType) {
    convertedSubs=new File(subsPath.getAbsolutePath() + File.separator + basename+ "String_Node_Str"+ params.sid.getId()+ "String_Node_Str"+ modId+ "String_Node_Str"+ subtitleType.getExtension());
  }
 else {
    String tmp=params.sid.getExternalFile().getName().replaceAll("String_Node_Str","String_Node_Str").trim();
    convertedSubs=new File(subsPath.getAbsolutePath() + File.separator + modId+ "String_Node_Str"+ tmp);
  }
  if (convertedSubs.canRead()) {
    if (applyFontConfig || isEmbeddedSource || is3D) {
      params.sid.setType(SubtitleType.ASS);
      params.sid.setExternalFileCharacterSet(CHARSET_UTF_8);
      if (is3D) {
        try {
          convertedSubs=convertASSToASS3D(convertedSubs,media,params);
        }
 catch (        IOException|NullPointerException e) {
          LOGGER.debug("String_Node_Str" + e);
          return null;
        }
      }
    }
    return convertedSubs;
  }
  boolean isExternalAss=false;
  if (params.sid.getType() == SubtitleType.ASS && params.sid.isExternal() && !isEmbeddedSource) {
    isExternalAss=true;
  }
  File tempSubs;
  if (isExternalAss || (!applyFontConfig && !isEmbeddedSource && (params.sid.getType() == subtitleType)&& (params.sid.getType() == SubtitleType.SUBRIP || params.sid.getType() == SubtitleType.WEBVTT)&& !is3D)) {
    tempSubs=params.sid.getExternalFile();
  }
 else {
    tempSubs=convertSubsToSubtitleType(filename,media,params,configuration,subtitleType);
  }
  if (tempSubs == null) {
    return null;
  }
  if (!FileUtil.isFileUTF8(tempSubs)) {
    try {
      tempSubs=applyCodepageConversion(tempSubs,convertedSubs);
      params.sid.setExternalFileCharacterSet(CHARSET_UTF_8);
    }
 catch (    IOException ex) {
      params.sid.setExternalFileCharacterSet(null);
      LOGGER.warn("String_Node_Str",ex);
    }
  }
 else {
    FileUtils.copyFile(tempSubs,convertedSubs);
    tempSubs=convertedSubs;
  }
  if (applyFontConfig && !(configuration.isUseEmbeddedSubtitlesStyle() && params.sid.getType() == SubtitleType.ASS)) {
    try {
      tempSubs=applyFontconfigToASSTempSubsFile(tempSubs,media,configuration);
      params.sid.setExternalFileCharacterSet(CHARSET_UTF_8);
    }
 catch (    IOException e) {
      LOGGER.debug("String_Node_Str" + e);
      return null;
    }
  }
  if (is3D) {
    try {
      tempSubs=convertASSToASS3D(tempSubs,media,params);
    }
 catch (    IOException|NullPointerException e) {
      LOGGER.debug("String_Node_Str" + e);
      return null;
    }
  }
  if (isEmbeddedSource) {
    params.sid.setExternalFile(tempSubs);
    params.sid.setType(SubtitleType.ASS);
  }
  PMS.get().addTempFile(tempSubs,30 * 24 * 3600* 1000);
  return tempSubs;
}

Fixed version (ground truth):
/** 
 * Extracts embedded subtitles from video to file in SSA/ASS format, converts external SRT subtitles file to SSA/ASS format and applies fontconfig setting to that converted file and applies timeseeking when required.
 * @param dlna DLNAResource
 * @param media DLNAMediaInfo
 * @param params Output parameters
 * @param configuration
 * @return Converted subtitle file
 * @throws IOException
 */
public static File getSubtitles(DLNAResource dlna,DLNAMediaInfo media,OutputParams params,PmsConfiguration configuration,SubtitleType subtitleType) throws IOException {
  if (media == null || params.sid.getId() == -1 || !params.sid.getType().isText()) {
    return null;
  }
  String dir=configuration.getDataFile(SUB_DIR);
  File subsPath=new File(dir);
  if (!subsPath.exists()) {
    subsPath.mkdirs();
  }
  boolean applyFontConfig=configuration.isFFmpegFontConfig();
  boolean isEmbeddedSource=params.sid.getId() < 100;
  boolean is3D=media.is3d() && !media.stereoscopyIsAnaglyph();
  String filename=isEmbeddedSource ? dlna.getSystemName() : params.sid.getExternalFile().getAbsolutePath();
  String basename;
  long modId=new File(filename).lastModified();
  if (modId != 0) {
    basename=FilenameUtils.getBaseName(filename);
  }
 else {
    basename=dlna.getName().replaceAll("String_Node_Str","String_Node_Str").trim();
    modId=filename.hashCode();
  }
  File convertedSubs;
  if (applyFontConfig || isEmbeddedSource || is3D|| params.sid.getType() != subtitleType) {
    convertedSubs=new File(subsPath.getAbsolutePath() + File.separator + basename+ "String_Node_Str"+ params.sid.getId()+ "String_Node_Str"+ modId+ "String_Node_Str"+ subtitleType.getExtension());
  }
 else {
    String tmp=params.sid.getExternalFile().getName().replaceAll("String_Node_Str","String_Node_Str").trim();
    convertedSubs=new File(subsPath.getAbsolutePath() + File.separator + modId+ "String_Node_Str"+ tmp);
  }
  if (convertedSubs.canRead()) {
    if (applyFontConfig || isEmbeddedSource || is3D) {
      params.sid.setType(SubtitleType.ASS);
      params.sid.setExternalFileCharacterSet(CHARSET_UTF_8);
      if (is3D) {
        try {
          convertedSubs=convertASSToASS3D(convertedSubs,media,params);
        }
 catch (        IOException|NullPointerException e) {
          LOGGER.debug("String_Node_Str" + e);
          return null;
        }
      }
    }
    return convertedSubs;
  }
  boolean isExternalAss=false;
  if (params.sid.getType() == SubtitleType.ASS && params.sid.isExternal() && !isEmbeddedSource) {
    isExternalAss=true;
  }
  File tempSubs;
  if (isExternalAss || (!applyFontConfig && !isEmbeddedSource && (params.sid.getType() == subtitleType)&& (params.sid.getType() == SubtitleType.SUBRIP || params.sid.getType() == SubtitleType.WEBVTT)&& !is3D)) {
    tempSubs=params.sid.getExternalFile();
  }
 else {
    tempSubs=convertSubsToSubtitleType(filename,media,params,configuration,subtitleType);
  }
  if (tempSubs == null) {
    return null;
  }
  if (!FileUtil.isFileUTF8(tempSubs)) {
    try {
      tempSubs=applyCodepageConversion(tempSubs,convertedSubs);
      params.sid.setExternalFileCharacterSet(CHARSET_UTF_8);
    }
 catch (    IOException ex) {
      params.sid.setExternalFileCharacterSet(null);
      LOGGER.warn("String_Node_Str",ex);
    }
  }
 else {
    FileUtils.copyFile(tempSubs,convertedSubs);
    tempSubs=convertedSubs;
  }
  if (applyFontConfig && !(configuration.isUseEmbeddedSubtitlesStyle() && params.sid.getType() == SubtitleType.ASS)) {
    try {
      tempSubs=applyFontconfigToASSTempSubsFile(tempSubs,media,configuration);
      params.sid.setExternalFileCharacterSet(CHARSET_UTF_8);
    }
 catch (    IOException e) {
      LOGGER.debug("String_Node_Str" + e);
      return null;
    }
  }
  if (is3D) {
    try {
      tempSubs=convertASSToASS3D(tempSubs,media,params);
    }
 catch (    IOException|NullPointerException e) {
      LOGGER.debug("String_Node_Str" + e);
      return null;
    }
  }
  if (isEmbeddedSource) {
    params.sid.setType(SubtitleType.ASS);
  }
  PMS.get().addTempFile(tempSubs,30 * 24 * 3600* 1000);
  return tempSubs;
}