kdfs: make free calls check for NULL.
[openssl.git] / providers / implementations / kdfs / pbkdf2.c
index 68aa0aa7c42779bcfe59fcfffa8a66532dce8d2d..077b93afb02c34fa7b25d1db0bc828401deb97df 100644 (file)
 #include "internal/cryptlib.h"
 #include "internal/numbers.h"
 #include "crypto/evp.h"
-#include "internal/provider_ctx.h"
-#include "internal/providercommonerr.h"
-#include "internal/provider_algs.h"
-#include "internal/provider_util.h"
+#include "prov/provider_ctx.h"
+#include "prov/providercommonerr.h"
+#include "prov/implementations.h"
+#include "prov/provider_util.h"
 #include "pbkdf2.h"
 
 /* Constants specified in SP800-132 */
@@ -80,8 +80,10 @@ static void kdf_pbkdf2_free(void *vctx)
 {
     KDF_PBKDF2 *ctx = (KDF_PBKDF2 *)vctx;
 
-    kdf_pbkdf2_cleanup(ctx);
-    OPENSSL_free(ctx);
+    if (ctx != NULL) {
+        kdf_pbkdf2_cleanup(ctx);
+        OPENSSL_free(ctx);
+    }
 }
 
 static void kdf_pbkdf2_reset(void *vctx)