From: Wootak Jung Date: Wed, 10 Mar 2021 05:42:02 +0000 (+0900) Subject: Fix GetLocalOobData memory leak (#2724) X-Git-Tag: citest_t1~236 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d29f5d53cabee80aaa8e24603f9b6b23a10ef4a6;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git Fix GetLocalOobData memory leak (#2724) Signed-off-by: Wootak Jung --- diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAdapterImpl.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAdapterImpl.cs index b2788c5..c2e8249 100644 --- a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAdapterImpl.cs +++ b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAdapterImpl.cs @@ -530,13 +530,20 @@ namespace Tizen.Network.Bluetooth 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; }