kdfs: make free calls check for NULL.
[openssl.git] / providers / implementations / kdfs / hkdf.c
index 333c2bafde10f82d2827a5b024f4a7f8fc6451fa..d9f53a67e722a7a7e5c8c43dd0b1b3979de52669 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 "e_os.h"
 
 #define HKDF_MAXBUF 1024
@@ -75,8 +75,10 @@ static void kdf_hkdf_free(void *vctx)
 {
     KDF_HKDF *ctx = (KDF_HKDF *)vctx;
 
-    kdf_hkdf_reset(ctx);
-    OPENSSL_free(ctx);
+    if (ctx != NULL) {
+        kdf_hkdf_reset(ctx);
+        OPENSSL_free(ctx);
+    }
 }
 
 static void kdf_hkdf_reset(void *vctx)