From 7c8d75f5a46a5bec3a8f6ea2a24958f848aaa206 Mon Sep 17 00:00:00 2001 From: Glavo Date: Sat, 7 Jan 2023 21:33:16 +0800 Subject: [PATCH] fix memory leak (#1986) --- .../main/java/org/jackhuang/hmcl/auth/offline/Texture.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/offline/Texture.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/offline/Texture.java index 761fab52a..9f3412fbb 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/offline/Texture.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/offline/Texture.java @@ -112,7 +112,10 @@ public class Texture { public static Texture loadTexture(InputStream in) throws IOException { if (in == null) return null; - BufferedImage img = ImageIO.read(in); + BufferedImage img; + try (InputStream is = in) { + img = ImageIO.read(is); + } if (img == null) { throw new IIOException("No image found"); }