From b6c3445785d7d68e23caf8f73da953f51ed6e5cf Mon Sep 17 00:00:00 2001 From: Micah Elizabeth Scott Date: Fri, 7 Mar 2014 21:19:54 -0800 Subject: [PATCH] Fix overflow if more than two frames are queued --- OpenPixelControl.pde | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/OpenPixelControl.pde b/OpenPixelControl.pde index 118eb2a..830ba6c 100644 --- a/OpenPixelControl.pde +++ b/OpenPixelControl.pde @@ -46,9 +46,10 @@ class OpenPixelControl extends SCPattern { bufferedByteCount = client.readBytes(buffer); } else { // Append to an earlier partial frame - byte[] additional = client.readBytes(); - arrayCopy(additional, 0, buffer, bufferedByteCount, additional.length); - bufferedByteCount += additional.length; + byte[] additional = new byte[buffer.length - bufferedByteCount]; + int additionalLength = client.readBytes(additional); + arrayCopy(additional, 0, buffer, bufferedByteCount, additionalLength); + bufferedByteCount += additionalLength; } // Extract OPC packets from buffer -- 2.34.1