Cfdocument causes NPE with orientation and fontDirectory

In 1.0.0.87 and lower I can specify both an “orientation” and a “fontDirectory” attribute on cfdocument.
Starting with 1.0.0.88 on up when I specify both parameters, I am getting a null pointer exception.

Code to reproduce:

<cfcontent type="application/pdf">
<cfdocument format="PDF" orientation="portrait" fontDirectory="c:/">
  <h1>Does crash</h1>
</cfdocument>

Full dump of crash:

java.lang.NullPointerException
 
The error occurred in C:\inetpub\wwwroot\navpointcx\index.cfm: line 3

1: <cfcontent type="application/pdf">
2: <cfdocument format="PDF" orientation="portrait" fontDirectory="c:/">
3:  <h1>Does crash</h1>
4: </cfdocument>
5: 
Browser  	Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36
Remote Address  	192.168.26.1
Referrer  	
Date/Time  	Thu, 12 Aug 2021 19:36:44 GMT
Stack Trace (click to expand)
lucee.runtime.exp.NativeException: java.lang.NullPointerException
	at org.lucee.extension.pdf.xhtmlrenderer.FSPDFDocument._render(FSPDFDocument.java:70)
	at org.lucee.extension.pdf.PDFDocument.render(PDFDocument.java:360)
	at org.lucee.extension.pdf.tag.Document.renderInital(Document.java:822)
	at org.lucee.extension.pdf.tag.Document._doAfterBody(Document.java:721)
	at org.lucee.extension.pdf.tag.Document.doAfterBody(Document.java:673)
	at index_cfm$cf$1xq.call(/index.cfm:3)
	at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1034)
	at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:926)
	at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:217)
	at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:44)
	at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2460)
	at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2450)
	at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2421)
	at lucee.runtime.engine.Request.exe(Request.java:45)
	at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1179)
	at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1125)
	at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:97)
	at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:51)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:432)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.NullPointerException
	... 40 more

OS: Windows
PDF Extension Version: 1.0.0.88-SNAPSHOT
Lucee Version: 5.3.8.201

1 Like

Changing the order of the attributes, putting fontDirectory first, also avoids the crash.

¯_(ツ)_/¯

1 Like

Already a bug filed for this issue https://luceeserver.atlassian.net/browse/LDEV-3575. A patch is also available.

2 Likes