From 620a859d5c0a2a5ea9fe33f6c679fc678c4b34cf Mon Sep 17 00:00:00 2001 From: Amos Ng Date: Mon, 29 Jun 2020 06:42:44 +0800 Subject: [PATCH] Properly close snapshot if referer invalid --- src/main/kotlin/mdnet/base/server/ImageServer.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/kotlin/mdnet/base/server/ImageServer.kt b/src/main/kotlin/mdnet/base/server/ImageServer.kt index dc7c633..dfe3b51 100644 --- a/src/main/kotlin/mdnet/base/server/ImageServer.kt +++ b/src/main/kotlin/mdnet/base/server/ImageServer.kt @@ -105,6 +105,10 @@ class ImageServer(private val cache: DiskLruCache, private val statistics: Atomi handled.set(true) if (referer != null && !referer.startsWith("https://mangadex.org")) { + if (snapshot != null) { + snapshot.close() + } + Response(Status.FORBIDDEN) } else if (snapshot != null && imageDatum != null) { request.handleCacheHit(sanitizedUri, getRc4(rc4Bytes), snapshot, imageDatum)