--- a/src/Pure/General/bytes.scala Sat Nov 23 11:19:18 2019 +0100
+++ b/src/Pure/General/bytes.scala Sat Nov 23 11:28:15 2019 +0100
@@ -66,7 +66,11 @@
}
def read(file: JFile): Bytes =
- using(new FileInputStream(file))(read_stream(_, limit = file.length.toInt))
+ {
+ val length = file.length
+ val limit = if (length < 0 || length > Integer.MAX_VALUE) Integer.MAX_VALUE else length.toInt
+ using(new FileInputStream(file))(read_stream(_, limit = limit))
+ }
def read(path: Path): Bytes = read(path.file)