Skip to content

Commit 9db17f9

Browse files
authored
Merge pull request #29 from kingthorin/npe-del-fix
2 parents fddc349 + 646c8cd commit 9db17f9

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
88
- Maintenance changes.
99
- The script example in the Help content was updated to use the injected core variables instead of using the fully qualified class name.
1010

11+
### Fixed
12+
- An NPE which could happen when removing an entry that didn't yet have a tag assigned.
13+
1114
## [1.5.0] - 2022-07-11
1215
### Added
1316
- A right-click context menu is now available in the History tab in order to Select/Set a color for arbitrary messages.

src/main/java/org/zaproxy/zap/extension/neonmarker/NeonmarkerPanel.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ private Component getRemoveButton(int ruleNumber) {
316316
return;
317317
}
318318
String tag = colormap.get(ruleNumber).getTag();
319-
if (ExtensionNeonmarker.TAG_PATTERN.matcher(tag).matches()) {
319+
if (tag != null && ExtensionNeonmarker.TAG_PATTERN.matcher(tag).matches()) {
320320
switch (getRemovalChoice()) {
321321
case JOptionPane.CANCEL_OPTION:
322322
case JOptionPane.CLOSED_OPTION:
@@ -332,19 +332,17 @@ private Component getRemoveButton(int ruleNumber) {
332332
return;
333333
}
334334
} else {
335-
colormap.remove(ruleNumber);
335+
removeMapping(ruleNumber);
336336
}
337337
refreshDisplay();
338338
});
339339
return remove;
340340
}
341341

342342
private void removeMapping(int ruleNumber) {
343-
if (colormap.size() == 1) {
344-
colormap.remove(ruleNumber);
343+
colormap.remove(ruleNumber);
344+
if (colormap.isEmpty()) {
345345
colormap.add(new ExtensionNeonmarker.ColorMapping());
346-
} else {
347-
colormap.remove(ruleNumber);
348346
}
349347
}
350348

0 commit comments

Comments
 (0)