From 32699f24975a7f2785619d696b7ace21d056daf6 Mon Sep 17 00:00:00 2001 From: YeungKC <11473691+YeungKC@users.noreply.github.com> Date: Sun, 18 Oct 2026 12:46:53 +0900 Subject: [PATCH] common_crypto: free the IV copy in AesCryptor The constructor copied the IV to native memory and did not free it, so each AesCryptor leaked the IV. CCCryptorCreate copies the IV, the same as the key, which is already freed after the call. Also free cryptorRef when CCCryptorCreate fails. --- packages/common_crypto/lib/src/aes.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/common_crypto/lib/src/aes.dart b/packages/common_crypto/lib/src/aes.dart index ef01dc25..10ed60de 100644 --- a/packages/common_crypto/lib/src/aes.dart +++ b/packages/common_crypto/lib/src/aes.dart @@ -76,8 +76,10 @@ class AesCryptor { cryptorRef, ); malloc.free(keyPointer); + malloc.free(ivPointer); if (status != kCCSuccess) { + malloc.free(cryptorRef); throw Exception('CCCryptorCreate failed: $status'); } _cryptorRef = cryptorRef.value;