For-in loop throws NullPointerException when located within finally block

Description

The for-in loop throws a NullPointerException when it is located within the finally-block. You can reproduce this with either of the following:

<cfscript> doIt({key1:"foo", key2:"bar", key3:"baz"}); public void function doIt(struct data) { try { writeOutput("trying<br>"); } finally { writeOutput("finally<br>"); for (var key in data) { writeOutput(key & "<br>"); } } } </cfscript> <cfscript> doIt(["a", "b"]); public void function doIt(array data) { try { writeOutput("trying<br>"); } finally { writeOutput("finally<br>"); for (var loopItem in data) { writeOutput(loopItem & "<br>"); } } } </cfscript>

Activity

Show:

Pothys - MitrahSoft 26 March 2021 at 10:27

I've checked this ticket and confirmed the issue happened on lucee latest version 5.3.8.162-SNAPSHOT also. Using for-loop inside the try/finally block throws an NPE. Seems ACF works fine. I added a testcase for this ticket

Pull Request: https://github.com/lucee/Lucee/pull/1252

Here is the stacktrace

lucee.runtime.exp.NativeException: java.lang.NullPointerException at org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source) at org.objectweb.asm.commons.GeneratorAdapter.endMethod(Unknown Source) at lucee.transformer.bytecode.Page.writeOutCall(Page.java:1477) at lucee.transformer.bytecode.Page.execute(Page.java:472) at lucee.runtime.compiler.CFMLCompilerImpl._compile(CFMLCompilerImpl.java:109) at lucee.runtime.compiler.CFMLCompilerImpl.compile(CFMLCompilerImpl.java:76) at lucee.runtime.PageSourceImpl._compile(PageSourceImpl.java:436) at lucee.runtime.PageSourceImpl.compile(PageSourceImpl.java:403) at lucee.runtime.PageSourceImpl.loadPhysical(PageSourceImpl.java:344) at lucee.runtime.PageSourceImpl.loadPageThrowTemplateException(PageSourceImpl.java:237) at lucee.runtime.PageSourceImpl.loadPage(PageSourceImpl.java:1014) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1015) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:912) at lucee.runtime.listener.ClassicAppListener._onRequest(ClassicAppListener.java:65) at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:45) at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2446) at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2436) at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2407) at lucee.runtime.engine.Request.exe(Request.java:44)

Details

Assignee

Reporter

Priority

Labels

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Affects versions

Created 25 March 2021 at 15:41
Updated 17 April 2023 at 06:18

Flag notifications