Fix issue: Softhsm-daemon leaks memory when certificate is stored master DEV.SOFTHSM-01.03.00.04
authorAntti Lyytinen <a-lyytinen@ti.com>
Fri, 27 Mar 2015 13:17:02 +0000 (15:17 +0200)
committerAntti Lyytinen <a-lyytinen@ti.com>
Fri, 27 Mar 2015 13:17:02 +0000 (15:17 +0200)
src/lib/object_store/FileSystem.cpp

index 322e811693443d7ea80486713f637484710a74de..663472bb65754a6eef36f665f9094c8b9f0e02c1 100644 (file)
@@ -1125,11 +1125,19 @@ bool FileSystem::checkHash()
 int FileSystem::getFSHashLength() const
 {
        int32_t const version = Configuration::i()->getInt("secstore.version", 2);
+       int len;
+       HashAlgorithm * hash;
        if(version < 3) {
-               return CryptoFactory::i()->getHashAlgorithm("md5")->getHashSize();
+               hash = CryptoFactory::i()->getHashAlgorithm("md5");
        } else {
-               return CryptoFactory::i()->getHashAlgorithm("hmacsha1")->getHashSize();
+               hash = CryptoFactory::i()->getHashAlgorithm("hmacsha1");
+       }
+       if (hash){
+               len = hash->getHashSize();
+               CryptoFactory::i()->recycleHashAlgorithm(hash);
+               return len;
        }
+       return -1;
 }