fix memory leak (#1986)

This commit is contained in:
Glavo 2023-01-07 21:33:16 +08:00 committed by GitHub
parent 1b5522958a
commit 7c8d75f5a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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");
}