From f260a11a0f64a0a6bc22513948d50c33fe80350e Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Sun, 30 Jul 2023 15:32:56 -0500 Subject: [PATCH] Fix copyBufferFromSource throwing an exception If usedBuffers was null and the buffer cache reached its maximum size, copyBufferFromSource would throw a null reference error. This adds a null check to that case to instantiate the usedBuffers list as is done elsewhere in this file. --- core/src/processing/opengl/Texture.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/src/processing/opengl/Texture.java b/core/src/processing/opengl/Texture.java index ecb67681b7..5624aa7725 100644 --- a/core/src/processing/opengl/Texture.java +++ b/core/src/processing/opengl/Texture.java @@ -823,11 +823,10 @@ public void copyBufferFromSource(Object natRef, ByteBuffer byteBuf, } else { // The buffer cache reached the maximum size, so we just dispose // the new buffer by adding it to the list of used buffers. - try { - usedBuffers.add(new BufferData(natRef, byteBuf.asIntBuffer(), w, h)); - } catch (Exception e) { - e.printStackTrace(); + if (usedBuffers == null) { + usedBuffers = new LinkedList(); } + usedBuffers.add(new BufferData(natRef, byteBuf.asIntBuffer(), w, h)); } } @@ -1667,4 +1666,4 @@ void dispose() { } } } -} \ No newline at end of file +}