1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-11 11:55:03 -05:00

Sanity check subtitle file size before doing any kind of language detection, as to avoid java.lang.OutOfMemoryError issues when dealing with oddly large files.

* https://www.filebot.net/forums/viewtopic.php?f=4&t=5867&p=40063#p40061
This commit is contained in:
Reinhard Pointner 2018-11-17 23:27:37 +07:00
parent 4b47452497
commit 9eb07913b5

View File

@ -454,10 +454,12 @@ public final class SubtitleUtilities {
} }
// detect language from subtitle text content // detect language from subtitle text content
MemoryFile data = new MemoryFile(file.getName(), ByteBuffer.wrap(readFile(file))); if (file.length() < ONE_MEGABYTE) {
List<DetectedLanguage> options = detectSubtitleLanguage(data); MemoryFile data = new MemoryFile(file.getName(), ByteBuffer.wrap(readFile(file)));
if (options.size() > 0) { List<DetectedLanguage> options = detectSubtitleLanguage(data);
return Language.getLanguage(options.get(0).getLocale().getLanguage()); if (options.size() > 0) {
return Language.getLanguage(options.get(0).getLocale().getLanguage());
}
} }
return null; return null;