From 69ba6dd0cb605d985af38ace72cc2536c6d5a0dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Lehmk=C3=BChler?= Date: Thu, 26 Sep 2024 06:18:54 +0000 Subject: [PATCH] PDFBOX-5852: don't create an unused array git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1920945 13f79535-47bb-0310-9956-ffa450edef68 --- .../pdfbox/pdmodel/graphics/shading/ShadedTriangle.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/ShadedTriangle.java b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/ShadedTriangle.java index fc7a03cb38a..f8683f86162 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/ShadedTriangle.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/ShadedTriangle.java @@ -232,11 +232,12 @@ private double getArea(Point2D a, Point2D b, Point2D c) public float[] calcColor(Point2D p) { int numberOfColorComponents = color[0].length; - float[] pCol = new float[numberOfColorComponents]; + float[] pCol = null; switch (degree) { case 1: + pCol = new float[numberOfColorComponents]; for (int i = 0; i < numberOfColorComponents; i++) { // average @@ -246,8 +247,10 @@ public float[] calcColor(Point2D p) case 2: // linear interpolation Point tp = new Point((int) Math.round(p.getX()), (int) Math.round(p.getY())); - return line.calcColor(tp); + pCol = line.calcColor(tp); + break; default: + pCol = new float[numberOfColorComponents]; float aw = (float) (getArea(p, corner[1], corner[2]) / area); float bw = (float) (getArea(p, corner[2], corner[0]) / area); float cw = (float) (getArea(p, corner[0], corner[1]) / area);