kdfs: make free calls check for NULL.
[openssl.git] / providers / implementations / kdfs / sskdf.c
index 1e538a9c0afc1b80a96ad54c1c7762303f8f95a8..2c4600d2058e0f758a240c40441822028ad4f578 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"
 
 typedef struct {
     void *provctx;
@@ -315,8 +315,10 @@ static void sskdf_free(void *vctx)
 {
     KDF_SSKDF *ctx = (KDF_SSKDF *)vctx;
 
-    sskdf_reset(ctx);
-    OPENSSL_free(ctx);
+    if (ctx != NULL) {
+        sskdf_reset(ctx);
+        OPENSSL_free(ctx);
+    }
 }
 
 static int sskdf_set_buffer(unsigned char **out, size_t *out_len,