Skip to content

Commit 0032aa0

Browse files
committed
Prevent NullPointerException when parsing annotations
1 parent 0070bc9 commit 0032aa0

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

base/src/main/java/proguard/ConfigurationParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ public ClassSpecification parseClassSpecificationArguments(boolean readFirstWord
850850
int requiredUnsetClassAccessFlags = 0;
851851

852852
// Parse the class annotations and access modifiers until the class keyword.
853-
while (!ConfigurationConstants.CLASS_KEYWORD.equals(nextWord))
853+
while (!ConfigurationConstants.CLASS_KEYWORD.equals(nextWord) && !configurationEnd(true))
854854
{
855855
// Strip the negating sign, if any.
856856
boolean negated =

base/src/test/kotlin/proguard/ConfigurationParserTest.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,17 @@ class ConfigurationParserTest : FreeSpec({
8282
}
8383
}
8484

85+
"A ParseException should be thrown with invalid annotation config at the end of the file" - {
86+
// This is a parse error without any further config after it.
87+
val configStr = ("-keep @MyAnnotation @ThisShouldBeInterfaceKeyword")
88+
89+
"Then the option should throw a ParseException" {
90+
shouldThrow<ParseException> {
91+
configStr.asConfiguration()
92+
}
93+
}
94+
}
95+
8596
"Wildcard type tests" - {
8697
class TestConfig(
8798
val configOption: String,

0 commit comments

Comments
 (0)