Skip to content

Commit

Permalink
fix null ptr during error message. add guard.
Browse files Browse the repository at this point in the history
  • Loading branch information
parrt committed Dec 27, 2012
1 parent df24931 commit 7bff6cf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/org/stringtemplate/v4/misc/ErrorManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
package org.stringtemplate.v4.misc;

import org.antlr.runtime.CharStream;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.Token;
import org.stringtemplate.v4.InstanceScope;
Expand Down Expand Up @@ -77,8 +78,12 @@ public ErrorManager(STErrorListener listener) {
}

public void compileTimeError(ErrorType error, Token templateToken, Token t) {
String srcName = t.getInputStream().getSourceName();
if ( srcName!=null ) srcName = Misc.getFileName(srcName);
CharStream input = t.getInputStream();
String srcName = null;
if ( input!=null ) {
srcName = input.getSourceName();
if ( srcName!=null ) srcName = Misc.getFileName(srcName);
}
listener.compileTimeError(
new STCompiletimeMessage(error,srcName,templateToken,t,null,t.getText())
);
Expand Down

0 comments on commit 7bff6cf

Please sign in to comment.