Skip to content

Commit

Permalink
Fixes #4792. Unhandled Java exception in Ripper on inline comments.
Browse files Browse the repository at this point in the history
We assumed all delayed token dispatches would have a valid delayed and we NPE
when we dup'd our ByteList.  MRI does not use an object like us and 0/NULL
ends up being nil.  Added simple check for null since we have no similar magic.
  • Loading branch information
enebo committed Oct 30, 2017
1 parent f6fd6e7 commit eb1151a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions core/src/main/java/org/jruby/ext/ripper/RipperLexer.java
Expand Up @@ -762,11 +762,10 @@ public void dispatchDelayedToken(int token) { //mri: rupper_dispatch_delayed_tok

ruby_sourceline = delayed_line;
tokp = lex_pbeg + delayed_col;

//System.out.println("TOKP: " + tokp + ", LEX_P: " + lex_p);
IRubyObject value = parser.getRuntime().newString(delayed.dup());

String event = tokenToEventId(token);
//System.out.println("EVENT: " + event + ", VALUE: " + value);
IRubyObject value = delayed == null ? parser.context.nil : parser.getRuntime().newString(delayed.dup());

yaccValue = parser.dispatch(event, value);
delayed = null;
ruby_sourceline = saved_line;
Expand Down

0 comments on commit eb1151a

Please sign in to comment.