Add fast-fail size check

This commit is contained in:
Him188 2020-02-07 12:32:41 +08:00
parent 80078ab25e
commit 8ad087c406

View File

@ -25,9 +25,13 @@ class ExternalImage(
val md5: ByteArray, val md5: ByteArray,
imageFormat: String, imageFormat: String,
val input: Input, val input: Input,
val inputSize: Long, val inputSize: Long, // dont be greater than Int.MAX
val filename: String val filename: String
) { ) {
init {
check(inputSize in Int.MIN_VALUE.toLong()..Int.MAX_VALUE.toLong()) { "file is too big" }
}
companion object { companion object {
operator fun invoke( operator fun invoke(
width: Int, width: Int,