diff --git a/app/src/main/java/org/thoughtcrime/securesms/glide/cache/ApngStreamCacheDecoder.java b/app/src/main/java/org/thoughtcrime/securesms/glide/cache/ApngStreamCacheDecoder.java index fdce779f78..37954ba1ee 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/glide/cache/ApngStreamCacheDecoder.java +++ b/app/src/main/java/org/thoughtcrime/securesms/glide/cache/ApngStreamCacheDecoder.java @@ -18,6 +18,9 @@ import java.nio.ByteBuffer; public class ApngStreamCacheDecoder implements ResourceDecoder { + /** Set to match {@link com.bumptech.glide.load.data.InputStreamRewinder}'s read limit */ + private static final int READ_LIMIT = 5 * 1024 * 1024; + private final ResourceDecoder byteBufferDecoder; public ApngStreamCacheDecoder(ResourceDecoder byteBufferDecoder) { @@ -27,7 +30,7 @@ public class ApngStreamCacheDecoder implements ResourceDecoder= readLimit) { + throw IOException("Read limit exceeded") + } + return reader.read(buffer, start, byteCount) + } + + @Throws(IOException::class) + override fun skip(total: Long): Long { + if (position() + total >= readLimit) { + throw IOException("Read limit exceeded") + } + return reader.skip(total) + } +}