Bug 1255 : endShape() throws java.lang.ArrayIndexOutOfBoundsException
Last modified: 2009-05-31 13:19




Status:
RESOLVED
Resolution:
FIXED -
Priority:
P2
Severity:
normal

 

Reporter:
DopeShow
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2009-05-30 15:13
When calling vertex() more than 512 times in POINTS mode, endShape throws
java.lang.ArrayIndexOutOfBoundsException:

Exception in thread "Animation Thread"
java.lang.ArrayIndexOutOfBoundsException: 512
at processing.core.PGraphics3D.addPoint(PGraphics3D.java:963)
at processing.core.PGraphics3D.endShapeStroke(PGraphics3D.java:693)
at processing.core.PGraphics3D.endShape(PGraphics3D.java:608)
at processing.core.PGraphics.endShape(PGraphics.java:1153)
at processing.core.PApplet.endShape(PApplet.java:6892)
at sketch_may30b.setup(sketch_may30b.java:21)
at processing.core.PApplet.handleDraw(PApplet.java:1400)
at processing.core.PApplet.run(PApplet.java:1328)
at java.lang.Thread.run(Thread.java:613)

Minimal code I could think of which produces the error:

size(100, 100, P3D);

beginShape(POINTS);
for (int i = 0; i < 513; ++i)
vertex(0, 0);
endShape();

It seems that PGraphics3D.addPoint() extends the lines-Array instead of the
points-Array. Changing

System.arraycopy(lines, 0, temp, 0, lineCount);
lines = temp;

to

System.arraycopy(points, 0, temp, 0, pointCount);
points = temp;

seems to work for me.

I'm running Processing 1.0.3 on a rather old MacBook with Mac OS X 10.5.7.
Additional Comment #1 From fry 2009-05-31 13:19
Thanks for tracking that down, now fixed for 1.0.4.