Browse Source

Memory leak

Source commit: 87d87fcd024f29d77298b0958f9aa5aa27ca5e01
Martin Prikryl 7 years ago
parent
commit
7097d1dac9
1 changed files with 8 additions and 0 deletions
  1. 8 0
      source/core/Cryptography.cpp

+ 8 - 0
source/core/Cryptography.cpp

@@ -651,10 +651,18 @@ TEncryption::TEncryption(const RawByteString & Key)
     FContext = call_aes_make_context();
     aes_set_encrypt_key(reinterpret_cast<unsigned char *>(FKey.c_str()), FKey.Length(), FContext);
   }
+  else
+  {
+    FContext = NULL;
+  }
 }
 //---------------------------------------------------------------------------
 TEncryption::~TEncryption()
 {
+  if (FContext != NULL)
+  {
+    call_aes_free_context(FContext);
+  }
   Shred(FKey);
   if ((FInputHeader.Length() > 0) && (FInputHeader.Length() < GetOverhead()))
   {