kdfs: make free calls check for NULL.
[openssl.git] / providers / implementations / kdfs / sshkdf.c
index 23a0caac5fb3a8bf25622dc9f50dcd23f3a65d57..508fb6350ade9d24362ae3f946bf60ec0282340f 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"
 
 /* See RFC 4253, Section 7.2 */
 static OSSL_OP_kdf_newctx_fn kdf_sshkdf_new;
@@ -63,8 +63,10 @@ static void kdf_sshkdf_free(void *vctx)
 {
     KDF_SSHKDF *ctx = (KDF_SSHKDF *)vctx;
 
-    kdf_sshkdf_reset(ctx);
-    OPENSSL_free(ctx);
+    if (ctx != NULL) {
+        kdf_sshkdf_reset(ctx);
+        OPENSSL_free(ctx);
+    }
 }
 
 static void kdf_sshkdf_reset(void *vctx)