Skip to content

Commit f260a11

Browse files
authored
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.
1 parent 781b4f7 commit f260a11

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

core/src/processing/opengl/Texture.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -823,11 +823,10 @@ public void copyBufferFromSource(Object natRef, ByteBuffer byteBuf,
823823
} else {
824824
// The buffer cache reached the maximum size, so we just dispose
825825
// the new buffer by adding it to the list of used buffers.
826-
try {
827-
usedBuffers.add(new BufferData(natRef, byteBuf.asIntBuffer(), w, h));
828-
} catch (Exception e) {
829-
e.printStackTrace();
826+
if (usedBuffers == null) {
827+
usedBuffers = new LinkedList<BufferData>();
830828
}
829+
usedBuffers.add(new BufferData(natRef, byteBuf.asIntBuffer(), w, h));
831830
}
832831
}
833832

@@ -1667,4 +1666,4 @@ void dispose() {
16671666
}
16681667
}
16691668
}
1670-
}
1669+
}

0 commit comments

Comments
 (0)