shevek / jcpp

The C Preprocessor as a Java library
http://www.anarres.org/projects/jcpp/
Apache License 2.0
106 stars 36 forks source link

NullPointerException when #endif is missing #16

Closed grzegorz8 closed 9 years ago

grzegorz8 commented 10 years ago

NullPointerException is thrown for source.setActive(true) in Preprocessor._token() when #endif is missing and #ifdef is satisfied. Here is a simple test case:

#define D
#ifdef D
    int a = 1;
#else
    int a = 2;
<EOF>

Similarly for:

#ifndef D
    int a = 1;
#else
    int a = 2;
<EOF>
shevek commented 9 years ago

Thank you. I will fix this. (Lazy Shevek asks:) Do you have a junit case?

shevek commented 9 years ago

Didn't have findbugs back in the day. Slowly adding JSR305 annotations in the hope of rattling out this kind of bug.