BluetoothErrorFactory.ThrowBluetoothException(ret);
}
- byte[] hashArr = new byte[hashLength];
- Marshal.Copy(hash, hashArr, 0, hashLength);
- byte[] randomizerArr = new byte[randomizerLength];
- Marshal.Copy(randomizer, randomizerArr, 0, randomizerLength);
+ if (hashLength > 0) {
+ byte[] hashArr = new byte[hashLength];
+ Marshal.Copy(hash, hashArr, 0, hashLength);
+ oobData.HashValue = hashArr;
+ Interop.Libc.Free(hash);
+ }
+
+ if (randomizerLength > 0) {
+ byte[] randomizerArr = new byte[randomizerLength];
+ Marshal.Copy(randomizer, randomizerArr, 0, randomizerLength);
+ oobData.RandomizerValue = randomizerArr;
+ Interop.Libc.Free(randomizer);
+ }
- oobData.HashValue = hashArr;
- oobData.RandomizerValue = randomizerArr;
return oobData;
}