Skip to content

Commit

Permalink
Fix NPE reported by Coverity (#24)
Browse files Browse the repository at this point in the history
* Fix NPE in ArgsConfiguration

* Join matcher checks together
  • Loading branch information
51-code authored Nov 18, 2024
1 parent ac52f38 commit 1b07c20
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/com/teragrep/cnf_01/ArgsConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public Map<String, String> asMap() throws ConfigurationException {
final Pattern ptn = Pattern.compile("([a-z]+)(=.+)");
for (final String arg : args) {
final Matcher matcher = ptn.matcher(arg);
if (!matcher.matches()) {
if (!matcher.matches() || matcher.group(1) == null | matcher.group(2) == null) {
throw new ConfigurationException(
String
.format(
Expand All @@ -88,6 +88,7 @@ public Map<String, String> asMap() throws ConfigurationException {
)
);
}

map.put(matcher.group(1), matcher.group(2).substring(1));
}
}
Expand Down

0 comments on commit 1b07c20

Please sign in to comment.