mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Fix write when used with long byte array.
If the byte array allocated is longer then the count passed to the write method, there will be a buffer overflow exception. Only put the number of bytes specified by count. Change-Id: I10ff48d5a5cf3f82c4e4e347326be033db300cdb
This commit is contained in:
@@ -378,7 +378,7 @@ public class SerialPort {
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
ByteBuffer dataToSendBuffer = ByteBuffer.allocateDirect(count);
|
||||
dataToSendBuffer.put(buffer);
|
||||
dataToSendBuffer.put(buffer, 0, count);
|
||||
int retVal = SerialPortJNI.serialWrite(m_port, dataToSendBuffer, count, status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
return retVal;
|
||||
|
||||
Reference in New Issue
Block a user