diff --git a/dlls/crypt32/chain.c b/dlls/crypt32/chain.c
index 056910faaa21fea4638972e74d1a753e54f161a4..aab2e91583bc45d4c02182b243bbe99bb453e26c 100644
--- a/dlls/crypt32/chain.c
+++ b/dlls/crypt32/chain.c
@@ -2293,7 +2293,10 @@ static BOOL CRYPT_BuildCandidateChainFromCert(CertificateChainEngine *engine,
             chain->context.dwRevocationFreshnessTime = 0;
         }
         else
+        {
+            CRYPT_FreeSimpleChain(simpleChain);
             ret = FALSE;
+        }
         *ppChain = chain;
     }
     return ret;