mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-22 15:58:52 -05:00
Do require minimum file size for libmediainfo calls to avoid libmediainfo crashing the JVM
This commit is contained in:
parent
d1a6301879
commit
cc059609c6
@ -42,7 +42,7 @@ public class MediaInfo implements MediaCharacteristics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized MediaInfo open(File file) throws IOException, IllegalArgumentException {
|
public synchronized MediaInfo open(File file) throws IOException, IllegalArgumentException {
|
||||||
if (!file.isFile()) {
|
if (!file.isFile() || file.length() < BUFFER_SIZE) {
|
||||||
throw new IllegalArgumentException("Invalid media file: " + file);
|
throw new IllegalArgumentException("Invalid media file: " + file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ public class MediaInfo implements MediaCharacteristics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean openViaBuffer(RandomAccessFile f) throws IOException {
|
private boolean openViaBuffer(RandomAccessFile f) throws IOException {
|
||||||
byte[] buffer = new byte[64 * 1024]; // use large buffer to reduce JNA calls
|
byte[] buffer = new byte[BUFFER_SIZE]; // use large buffer to reduce JNA calls
|
||||||
int read = -1;
|
int read = -1;
|
||||||
|
|
||||||
if (0 == MediaInfoLibrary.INSTANCE.Open_Buffer_Init(handle, f.length(), 0)) {
|
if (0 == MediaInfoLibrary.INSTANCE.Open_Buffer_Init(handle, f.length(), 0)) {
|
||||||
@ -361,4 +361,6 @@ public class MediaInfo implements MediaCharacteristics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final int BUFFER_SIZE = 64 * 1024;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user