From 4ebfde1ba0133a1807cf9dbbf637cea086e0d81b Mon Sep 17 00:00:00 2001 From: Carlos Amengual Date: Thu, 15 Aug 2024 09:55:05 +0200 Subject: [PATCH] bridge: fix a resource leak in `BaseScriptingEnvironment` --- .../echosvg/bridge/BaseScriptingEnvironment.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/echosvg-bridge/src/main/java/io/sf/carte/echosvg/bridge/BaseScriptingEnvironment.java b/echosvg-bridge/src/main/java/io/sf/carte/echosvg/bridge/BaseScriptingEnvironment.java index c49ae2722..db2f8ab8b 100644 --- a/echosvg-bridge/src/main/java/io/sf/carte/echosvg/bridge/BaseScriptingEnvironment.java +++ b/echosvg-bridge/src/main/java/io/sf/carte/echosvg/bridge/BaseScriptingEnvironment.java @@ -361,13 +361,13 @@ protected void loadScript(AbstractElement script) { // Java code invocation. // if (type.equals(SVGConstants.SVG_SCRIPT_TYPE_JAVA)) { + DocumentJarClassLoader cll = null; try { String href = XLinkSupport.getXLinkHref(script); ParsedURL purl = new ParsedURL(script.getBaseURI(), href); checkCompatibleScriptURL(type, purl); - DocumentJarClassLoader cll; URL docURL = null; try { docURL = new URL(docPURL.toString()); @@ -411,6 +411,15 @@ protected void loadScript(AbstractElement script) { if (userAgent != null) { userAgent.displayError(e); } + } finally { + try { + if (cll != null) + cll.close(); + } catch (IOException e) { + if (userAgent != null) { + userAgent.displayError(e); + } + } } return; }