Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
trashgod committed Apr 17, 2024
1 parent b9a36f2 commit 6e7f7d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/jfree/chart/plot/CompassPlot.java
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ public void setSeriesNeedle(int index, int type) {
* @param needle the needle.
*/
public void setSeriesNeedle(int index, MeterNeedle needle) {
if ((needle != null) && (index < this.seriesNeedle.length)) {
if ((needle != null) && (index >= 0) && (index < this.seriesNeedle.length)) {
this.seriesNeedle[index] = needle;
}
fireChangeEvent();
Expand Down
11 changes: 10 additions & 1 deletion src/test/java/org/jfree/chart/plot/CompassPlotTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import java.awt.GradientPaint;

import org.jfree.chart.TestUtils;

import org.jfree.chart.needle.PointerNeedle;
import org.jfree.data.general.DefaultValueDataset;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -132,4 +132,13 @@ public void testCloning() throws CloneNotSupportedException {
assertEquals(p1, p2);
}

/**
* Test faulty array bounds; CVE-2024-23077.
*/
@Test
public void testArrayBounds() {
CompassPlot p = new CompassPlot(new DefaultValueDataset(0));
p.setSeriesNeedle(-1, new PointerNeedle());
}

}

0 comments on commit 6e7f7d2

Please sign in to comment.