memset, memcpy, sizeof consistency fixes
[openssl.git] / crypto / evp / pmeth_lib.c
index 9f81d10021a065d820025896575924c90f0a4297..eeee53a2efbf26f4bf3747b340f283c3d6b1c197 100644 (file)
@@ -65,8 +65,8 @@
 #ifndef OPENSSL_NO_ENGINE
 # include <openssl/engine.h>
 #endif
-#include "asn1_locl.h"
-#include "evp_locl.h"
+#include "internal/asn1_int.h"
+#include "internal/evp_int.h"
 
 typedef int sk_cmp_fn_type(const char *const *a, const char *const *b);
 
@@ -165,7 +165,7 @@ static EVP_PKEY_CTX *int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id)
         return NULL;
     }
 
-    ret = OPENSSL_malloc(sizeof(EVP_PKEY_CTX));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (!ret) {
 #ifndef OPENSSL_NO_ENGINE
         if (e)
@@ -197,11 +197,12 @@ static EVP_PKEY_CTX *int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id)
 EVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags)
 {
     EVP_PKEY_METHOD *pmeth;
-    pmeth = OPENSSL_malloc(sizeof(EVP_PKEY_METHOD));
+
+    pmeth = OPENSSL_malloc(sizeof(*pmeth));
     if (!pmeth)
         return NULL;
 
-    memset(pmeth, 0, sizeof(EVP_PKEY_METHOD));
+    memset(pmeth, 0, sizeof(*pmeth));
 
     pmeth->pkey_id = id;
     pmeth->flags = flags | EVP_PKEY_FLAG_DYNAMIC;
@@ -313,7 +314,7 @@ EVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *pctx)
         return 0;
     }
 #endif
-    rctx = OPENSSL_malloc(sizeof(EVP_PKEY_CTX));
+    rctx = OPENSSL_malloc(sizeof(*rctx));
     if (!rctx)
         return NULL;
 
@@ -363,10 +364,8 @@ void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx)
         return;
     if (ctx->pmeth && ctx->pmeth->cleanup)
         ctx->pmeth->cleanup(ctx);
-    if (ctx->pkey)
-        EVP_PKEY_free(ctx->pkey);
-    if (ctx->peerkey)
-        EVP_PKEY_free(ctx->peerkey);
+    EVP_PKEY_free(ctx->pkey);
+    EVP_PKEY_free(ctx->peerkey);
 #ifndef OPENSSL_NO_ENGINE
     if (ctx->engine)
         /*