ByteArray: add defensive copy in bytes() getter

This commit is contained in:
Sean Gilligan 2023-08-14 08:03:25 -07:00 committed by Andreas Schildbach
parent 49f7ddbc0f
commit 07ca73cce7

View File

@ -38,7 +38,9 @@ public class ByteArray implements Comparable<ByteArray> {
* @return the key bytes
*/
public byte[] bytes() {
return bytes;
byte[] copy = new byte[bytes.length];
System.arraycopy(bytes, 0, copy, 0, bytes.length);
return copy;
}
/**