kdfs: make free calls check for NULL.
[openssl.git] / providers / implementations / kdfs / pbkdf2.c
index d1047c6e2ccfee96ecf19fa3f1913631b1208053..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 "prov/provider_ctx.h"
+#include "prov/providercommonerr.h"
 #include "prov/implementations.h"
-#include "internal/provider_util.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)