# HG changeset patch
# User rkennke
# Date 1254777142 -7200
# Node ID ccc36189f2a7615ffb798e76ba5b31d8c535dc40
# Parent  31e68419715e0a8e88ee6005ab1d69180cfe6f44
6887494: NPE in pisces Renderer
Summary: Only recreate crossings array, if there actually exists one before.
Reviewed-by: flar, tdv

diff -r 31e68419715e -r ccc36189f2a7 src/share/classes/sun/java2d/pisces/Renderer.java
--- openjdk.orig/jdk/src/share/classes/sun/java2d/pisces/Renderer.java	Fri Oct 02 10:15:12 2009 -0700
+++ openjdk/jdk/src/share/classes/sun/java2d/pisces/Renderer.java	Mon Oct 05 23:12:22 2009 +0200
@@ -775,10 +775,12 @@
 
     // Free sorting arrays if larger than maximum size
     private void crossingListFinished() {
-        if (crossings.length > DEFAULT_CROSSINGS_SIZE) {
+        if (crossings != null && crossings.length > DEFAULT_CROSSINGS_SIZE) {
             crossings = new int[DEFAULT_CROSSINGS_SIZE];
         }
-        if (crossingIndices.length > DEFAULT_INDICES_SIZE) {
+        if (crossingIndices != null &&
+            crossingIndices.length > DEFAULT_INDICES_SIZE)
+        {
             crossingIndices = new int[DEFAULT_INDICES_SIZE];
         }
     }
diff -r 31e68419715e -r ccc36189f2a7 test/sun/java2d/pisces/Renderer/TestNPE.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ openjdk/jdk/test/sun/java2d/pisces/Renderer/TestNPE.java	Mon Oct 05 23:12:22 2009 +0200
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions. 
+ */
+
+/**
+ * @test
+ * @bug     6887494
+ *
+ * @summary Verifies that no NullPointerException is thrown in Pisces Renderer
+ *          under certain circumstances.
+ *
+ * @run     main TestNPE
+ */
+
+import java.awt.*;
+import java.awt.geom.*;
+import java.awt.image.BufferedImage;
+
+public class TestNPE {
+
+    private static void paint(Graphics g) {
+        Graphics2D g2d = (Graphics2D) g;
+        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+                             RenderingHints.VALUE_ANTIALIAS_ON);
+        g2d.setClip(0, 0, 0, 0);
+        g2d.setTransform(
+               new AffineTransform(4.0f, 0.0f, 0.0f, 4.0f, -1248.0f, -744.0f));
+        g2d.draw(new Line2D.Float(131.21428571428572f, 33.0f,
+                                  131.21428571428572f, 201.0f));
+    }
+
+    public static void main(String[] args) {
+        BufferedImage im = new BufferedImage(100, 100,
+                                             BufferedImage.TYPE_INT_ARGB);
+
+        // Trigger exception in main thread.
+        Graphics g = im.getGraphics();
+        paint(g);
+    }
+}
