Skip to content

Commit

Permalink
Prevent NullPointerException when parsing annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
fergal-whyte committed Oct 25, 2023
1 parent 0070bc9 commit 0032aa0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/src/main/java/proguard/ConfigurationParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ public ClassSpecification parseClassSpecificationArguments(boolean readFirstWord
int requiredUnsetClassAccessFlags = 0;

// Parse the class annotations and access modifiers until the class keyword.
while (!ConfigurationConstants.CLASS_KEYWORD.equals(nextWord))
while (!ConfigurationConstants.CLASS_KEYWORD.equals(nextWord) && !configurationEnd(true))
{
// Strip the negating sign, if any.
boolean negated =
Expand Down
11 changes: 11 additions & 0 deletions base/src/test/kotlin/proguard/ConfigurationParserTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ class ConfigurationParserTest : FreeSpec({
}
}

"A ParseException should be thrown with invalid annotation config at the end of the file" - {
// This is a parse error without any further config after it.
val configStr = ("-keep @MyAnnotation @ThisShouldBeInterfaceKeyword")

"Then the option should throw a ParseException" {
shouldThrow<ParseException> {
configStr.asConfiguration()
}
}
}

"Wildcard type tests" - {
class TestConfig(
val configOption: String,
Expand Down

0 comments on commit 0032aa0

Please sign in to comment.