[openssl-commits] [openssl] master update

Rich Salz rsalz at openssl.org
Mon May 4 19:00:27 UTC 2015


The branch master has been updated
       via  b4faea50c35d92a67d1369355b49cc3efba78406 (commit)
      from  8920a7cd04f43b1a090d0b0a8c9e16b94c6898d4 (commit)


- Log -----------------------------------------------------------------
commit b4faea50c35d92a67d1369355b49cc3efba78406
Author: Rich Salz <rsalz at akamai.com>
Date:   Fri May 1 23:10:31 2015 -0400

    Use safer sizeof variant in malloc
    
    For a local variable:
            TYPE *p;
    Allocations like this are "risky":
            p = OPENSSL_malloc(sizeof(TYPE));
    if the type of p changes, and the malloc call isn't updated, you
    could get memory corruption.  Instead do this:
            p = OPENSSL_malloc(sizeof(*p));
    Also fixed a few memset() calls that I noticed while doing this.
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 apps/apps.c                         |  9 +++++----
 apps/ca.c                           |  4 ++--
 apps/cms.c                          |  2 +-
 apps/ecparam.c                      |  2 +-
 apps/openssl.c                      |  2 +-
 apps/s_cb.c                         |  2 +-
 apps/s_server.c                     |  6 +++---
 apps/speed.c                        |  2 +-
 apps/srp.c                          |  2 +-
 apps/vms_decc_init.c                |  2 +-
 crypto/LPdir_unix.c                 |  4 ++--
 crypto/LPdir_vms.c                  |  4 ++--
 crypto/LPdir_win.c                  |  4 ++--
 crypto/asn1/a_object.c              |  2 +-
 crypto/asn1/a_strnid.c              |  2 +-
 crypto/asn1/ameth_lib.c             |  2 +-
 crypto/asn1/asn1_lib.c              |  2 +-
 crypto/asn1/asn_mime.c              |  4 ++--
 crypto/asn1/bio_asn1.c              |  2 +-
 crypto/asn1/bio_ndef.c              |  2 +-
 crypto/asn1/tasn_new.c              |  2 +-
 crypto/asn1/tasn_prn.c              |  2 +-
 crypto/asn1/tasn_scn.c              |  2 +-
 crypto/asn1/x_crl.c                 |  2 +-
 crypto/asn1/x_info.c                |  2 +-
 crypto/asn1/x_pkey.c                |  4 ++--
 crypto/bio/bf_buff.c                |  3 +--
 crypto/bio/bf_lbuf.c                |  2 +-
 crypto/bio/bf_nbio.c                |  2 +-
 crypto/bio/bio_lib.c                |  3 +--
 crypto/bio/bss_acpt.c               |  2 +-
 crypto/bio/bss_bio.c                |  2 +-
 crypto/bio/bss_conn.c               |  2 +-
 crypto/bio/bss_dgram.c              |  4 ++--
 crypto/bn/Makefile                  | 14 +++++++-------
 crypto/bn/bn_blind.c                |  2 +-
 crypto/bn/bn_ctx.c                  |  4 ++--
 crypto/bn/bn_gf2m.c                 | 10 +++++-----
 crypto/bn/bn_lib.c                  |  6 +++---
 crypto/bn/bn_mont.c                 |  2 +-
 crypto/bn/bn_recp.c                 |  2 +-
 crypto/buffer/buffer.c              |  2 +-
 crypto/cmac/cmac.c                  |  3 ++-
 crypto/comp/c_zlib.c                |  4 ++--
 crypto/comp/comp_lib.c              |  2 +-
 crypto/conf/conf_api.c              |  2 +-
 crypto/conf/conf_def.c              |  4 ++--
 crypto/conf/conf_mod.c              |  4 ++--
 crypto/dh/dh_lib.c                  |  2 +-
 crypto/dh/dh_pmeth.c                |  2 +-
 crypto/dsa/dsa_asn1.c               |  2 +-
 crypto/dsa/dsa_lib.c                |  2 +-
 crypto/dsa/dsa_pmeth.c              |  2 +-
 crypto/dso/dso_lib.c                |  2 +-
 crypto/dso/dso_vms.c                |  2 +-
 crypto/dso/dso_win32.c              |  4 ++--
 crypto/ec/Makefile                  | 11 ++++++-----
 crypto/ec/ec_key.c                  |  3 +--
 crypto/ec/ec_lib.c                  | 10 +++++-----
 crypto/ec/ec_mult.c                 |  8 ++++----
 crypto/ec/ec_pmeth.c                |  3 ++-
 crypto/ec/ecp_nistp224.c            |  4 ++--
 crypto/ec/ecp_nistp256.c            |  4 ++--
 crypto/ec/ecp_nistp521.c            |  4 ++--
 crypto/ec/ecp_nistz256.c            |  4 ++--
 crypto/ecdh/ech_lib.c               |  2 +-
 crypto/ecdsa/ecs_lib.c              |  4 ++--
 crypto/engine/eng_dyn.c             |  4 ++--
 crypto/engine/eng_lib.c             |  4 ++--
 crypto/engine/eng_openssl.c         |  2 +-
 crypto/engine/eng_table.c           |  2 +-
 crypto/err/err.c                    |  6 +++---
 crypto/evp/bio_b64.c                |  2 +-
 crypto/evp/bio_enc.c                |  2 +-
 crypto/evp/bio_ok.c                 |  2 +-
 crypto/evp/digest.c                 |  8 ++++----
 crypto/evp/evp_enc.c                |  4 ++--
 crypto/evp/evp_pbe.c                |  3 ++-
 crypto/evp/p_lib.c                  |  2 +-
 crypto/evp/pmeth_lib.c              |  7 ++++---
 crypto/ex_data.c                    |  4 ++--
 crypto/hmac/hm_pmeth.c              |  2 +-
 crypto/hmac/hmac.c                  |  2 +-
 crypto/jpake/jpake.c                |  4 ++--
 crypto/lhash/lhash.c                |  6 +++---
 crypto/lock.c                       |  2 +-
 crypto/mem_dbg.c                    |  4 ++--
 crypto/modes/gcm128.c               |  2 +-
 crypto/modes/ocb128.c               |  2 +-
 crypto/objects/Makefile             |  8 ++++----
 crypto/objects/o_names.c            |  8 ++++----
 crypto/objects/obj_dat.c            | 11 ++++-------
 crypto/objects/obj_xref.c           |  2 +-
 crypto/ocsp/ocsp_ht.c               |  4 ++--
 crypto/pqueue/pqueue.c              |  4 ++--
 crypto/rsa/rsa_lib.c                |  2 +-
 crypto/rsa/rsa_pmeth.c              |  2 +-
 crypto/srp/srp_vfy.c                |  8 ++++----
 crypto/stack/stack.c                |  4 ++--
 crypto/store/str_lib.c              | 13 +++++++------
 crypto/store/str_mem.c              |  2 +-
 crypto/store/str_meth.c             |  2 +-
 crypto/ts/ts_rsp_sign.c             |  2 +-
 crypto/ts/ts_verify_ctx.c           |  2 +-
 crypto/txt_db/txt_db.c              |  2 +-
 crypto/ui/ui_lib.c                  |  6 +++---
 crypto/x509/by_dir.c                |  6 +++---
 crypto/x509/x509_lu.c               |  8 ++++----
 crypto/x509/x509_trs.c              |  2 +-
 crypto/x509/x509_vfy.c              |  3 +--
 crypto/x509/x509_vpm.c              |  8 ++++----
 crypto/x509/x_name.c                |  4 ++--
 crypto/x509v3/pcy_cache.c           |  2 +-
 crypto/x509v3/pcy_data.c            |  2 +-
 crypto/x509v3/pcy_node.c            |  2 +-
 crypto/x509v3/pcy_tree.c            |  4 ++--
 crypto/x509v3/v3_asid.c             |  2 +-
 crypto/x509v3/v3_lib.c              |  2 +-
 crypto/x509v3/v3_purp.c             |  2 +-
 crypto/x509v3/v3_scts.c             |  2 +-
 crypto/x509v3/v3_utl.c              |  2 +-
 demos/state_machine/state_machine.c |  2 +-
 engines/ccgost/gost_pmeth.c         |  7 ++++---
 engines/e_capi.c                    |  8 ++++----
 engines/e_chil.c                    |  2 +-
 engines/e_gmp.c                     |  3 ++-
 ssl/bio_ssl.c                       |  3 +--
 ssl/d1_both.c                       |  2 +-
 ssl/d1_lib.c                        |  4 ++--
 ssl/record/rec_layer_d1.c           |  7 +++----
 ssl/s3_enc.c                        |  4 ++--
 ssl/s3_lib.c                        |  8 ++++----
 ssl/ssl_cert.c                      | 10 ++++------
 ssl/ssl_ciph.c                      |  8 ++++----
 ssl/ssl_conf.c                      |  4 ++--
 ssl/ssl_lib.c                       |  4 ++--
 ssl/ssl_sess.c                      |  2 +-
 ssl/t1_enc.c                        |  2 +-
 test/Makefile                       | 23 ++++++++++++-----------
 test/ecdsatest.c                    |  4 +---
 test/ectest.c                       |  4 +---
 test/evp_test.c                     | 10 +++++-----
 142 files changed, 278 insertions(+), 283 deletions(-)

diff --git a/apps/apps.c b/apps/apps.c
index 1e2970a..797e250 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -180,7 +180,7 @@ int chopup_args(ARGS *arg, char *buf)
     arg->argc = 0;
     if (arg->size == 0) {
         arg->size = 20;
-        arg->argv = app_malloc(sizeof(char *) * arg->size, "argv space");
+        arg->argv = app_malloc(sizeof(*arg->argv) * arg->size, "argv space");
         if (arg->argv == NULL)
             return 0;
     }
@@ -195,7 +195,8 @@ int chopup_args(ARGS *arg, char *buf)
         /* The start of something good :-) */
         if (arg->argc >= arg->size) {
             arg->size += 20;
-            arg->argv = OPENSSL_realloc(arg->argv, sizeof(char *) * arg->size);
+            arg->argv = OPENSSL_realloc(arg->argv,
+                                        sizeof(*arg->argv) * arg->size);
             if (arg->argv == NULL)
                 return 0;
         }
@@ -1585,7 +1586,7 @@ CA_DB *load_index(char *dbfile, DB_ATTR *db_attr)
         }
     }
 
-    retdb = app_malloc(sizeof *retdb, "new DB");
+    retdb = app_malloc(sizeof(*retdb), "new DB");
     retdb->db = tmpdb;
     tmpdb = NULL;
     if (db_attr)
@@ -2364,7 +2365,7 @@ static int WIN32_rename(const char *from, const char *to)
     } else {                    /* UNICODE path */
 
         size_t i, flen = strlen(from) + 1, tlen = strlen(to) + 1;
-        tfrom = (TCHAR *)malloc(sizeof(TCHAR) * (flen + tlen));
+        tfrom = malloc(*sizeof(*tfrom) * (flen + tlen));
         if (tfrom == NULL)
             goto err;
         tto = tfrom + flen;
diff --git a/apps/ca.c b/apps/ca.c
index b6cf47f..abce534 100644
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -1970,7 +1970,7 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
     row[DB_type][0] = 'V';
     row[DB_type][1] = '\0';
 
-    irow = app_malloc(sizeof(char *) * (DB_NUMBER + 1), "row space");
+    irow = app_malloc(sizeof(*irow) * (DB_NUMBER + 1), "row space");
     for (i = 0; i < DB_NUMBER; i++) {
         irow[i] = row[i];
         row[i] = NULL;
@@ -2207,7 +2207,7 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value)
         row[DB_type][0] = 'V';
         row[DB_type][1] = '\0';
 
-        irow = app_malloc(sizeof(char *) * (DB_NUMBER + 1), "row ptr");
+        irow = app_malloc(sizeof(*irow) * (DB_NUMBER + 1), "row ptr");
         for (i = 0; i < DB_NUMBER; i++) {
             irow[i] = row[i];
             row[i] = NULL;
diff --git a/apps/cms.c b/apps/cms.c
index 79d0b8f..5eb5d2d 100644
--- a/apps/cms.c
+++ b/apps/cms.c
@@ -570,7 +570,7 @@ int cms_main(int argc, char **argv)
             }
             if (key_param == NULL || key_param->idx != keyidx) {
                 cms_key_param *nparam;
-                nparam = app_malloc(sizeof *nparam, "key param buffer");
+                nparam = app_malloc(sizeof(*nparam), "key param buffer");
                 nparam->idx = keyidx;
                 if ((nparam->param = sk_OPENSSL_STRING_new_null()) == NULL)
                     goto end;
diff --git a/apps/ecparam.c b/apps/ecparam.c
index dd0e8f5..5ceaec7 100644
--- a/apps/ecparam.c
+++ b/apps/ecparam.c
@@ -232,7 +232,7 @@ int ecparam_main(int argc, char **argv)
         size_t crv_len = EC_get_builtin_curves(NULL, 0);
         size_t n;
 
-        curves = app_malloc((int)(sizeof *curves * crv_len), "list curves");
+        curves = app_malloc((int)sizeof(*curves) * crv_len, "list curves");
         if (!EC_get_builtin_curves(curves, crv_len)) {
             OPENSSL_free(curves);
             goto end;
diff --git a/apps/openssl.c b/apps/openssl.c
index b71f3d1..fa3b683 100644
--- a/apps/openssl.c
+++ b/apps/openssl.c
@@ -804,7 +804,7 @@ static LHASH_OF(FUNCTION) *prog_init(void)
 
     /* Sort alphabetically within category. For nicer help displays. */
     for (i = 0, f = functions; f->name != NULL; ++f, ++i) ;
-    qsort(functions, i, sizeof *functions, SortFnByName);
+    qsort(functions, i, sizeof(*functions), SortFnByName);
 
     if ((ret = lh_FUNCTION_new()) == NULL)
         return (NULL);
diff --git a/apps/s_cb.c b/apps/s_cb.c
index 13a3a25..d371cc9 100644
--- a/apps/s_cb.c
+++ b/apps/s_cb.c
@@ -1173,7 +1173,7 @@ void ssl_ctx_set_excert(SSL_CTX *ctx, SSL_EXCERT *exc)
 
 static int ssl_excert_prepend(SSL_EXCERT **pexc)
 {
-    SSL_EXCERT *exc = app_malloc(sizeof *exc, "prepend cert");
+    SSL_EXCERT *exc = app_malloc(sizeof(*exc), "prepend cert");
 
     exc->certfile = NULL;
     exc->keyfile = NULL;
diff --git a/apps/s_server.c b/apps/s_server.c
index fead620..c1b799f 100644
--- a/apps/s_server.c
+++ b/apps/s_server.c
@@ -461,7 +461,7 @@ static int ebcdic_new(BIO *bi)
 {
     EBCDIC_OUTBUFF *wbuf;
 
-    wbuf = app_malloc(sizeof(EBCDIC_OUTBUFF) + 1024, "ebcdef wbuf");
+    wbuf = app_malloc(sizeof(*wbuf) + 1024, "ebcdic wbuf");
     wbuf->alloced = 1024;
     wbuf->buff[0] = '\0';
 
@@ -515,7 +515,7 @@ static int ebcdic_write(BIO *b, const char *in, int inl)
         num = num + num;        /* double the size */
         if (num < inl)
             num = inl;
-        wbuf = app_malloc(sizeof(EBCDIC_OUTBUFF) + num, "grow ebcdic wbuf");
+        wbuf = app_malloc(sizeof(*wbuf) + num, "grow ebcdic wbuf");
         OPENSSL_free(b->ptr);
 
         wbuf->alloced = num;
@@ -3127,7 +3127,7 @@ static simple_ssl_session *first = NULL;
 
 static int add_session(SSL *ssl, SSL_SESSION *session)
 {
-    simple_ssl_session *sess = app_malloc(sizeof *sess, "get session");
+    simple_ssl_session *sess = app_malloc(sizeof(*sess), "get session");
     unsigned char *p;
 
     SSL_SESSION_get_id(session, &sess->idlen);
diff --git a/apps/speed.c b/apps/speed.c
index 7a69485..00c7c41 100644
--- a/apps/speed.c
+++ b/apps/speed.c
@@ -2283,7 +2283,7 @@ static int do_multi(int multi)
     int *fds;
     static char sep[] = ":";
 
-    fds = malloc(multi * sizeof *fds);
+    fds = malloc(sizeof(*fds) * multi);
     for (n = 0; n < multi; ++n) {
         if (pipe(fd) == -1) {
             fprintf(stderr, "pipe failure\n");
diff --git a/apps/srp.c b/apps/srp.c
index 8b44780..c7a93cf 100644
--- a/apps/srp.c
+++ b/apps/srp.c
@@ -138,7 +138,7 @@ static int update_index(CA_DB *db, char **row)
     char **irow;
     int i;
 
-    irow = app_malloc(sizeof(char *) * (DB_NUMBER + 1), "row pointers");
+    irow = app_malloc(sizeof(*irow) * (DB_NUMBER + 1), "row pointers");
     for (i = 0; i < DB_NUMBER; i++) {
         irow[i] = row[i];
         row[i] = NULL;
diff --git a/apps/vms_decc_init.c b/apps/vms_decc_init.c
index 3ec7b54..2b273ac 100644
--- a/apps/vms_decc_init.c
+++ b/apps/vms_decc_init.c
@@ -130,7 +130,7 @@ char **copy_argv(int *argc, char *argv[])
      */
 
     int i, count = *argc;
-    char **newargv = app_malloc((count + 1) * sizeof *newargv, "argv copy");
+    char **newargv = app_malloc(sizeof(*newargv) * (count + 1), "argv copy");
 
     for (i = 0; i < count; i++)
         newargv[i] = argv[i];
diff --git a/crypto/LPdir_unix.c b/crypto/LPdir_unix.c
index bead6ab..3a14da1 100644
--- a/crypto/LPdir_unix.c
+++ b/crypto/LPdir_unix.c
@@ -78,12 +78,12 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
 
     errno = 0;
     if (*ctx == NULL) {
-        *ctx = (LP_DIR_CTX *)malloc(sizeof(LP_DIR_CTX));
+        *ctx = malloc(sizeof(**ctx));
         if (*ctx == NULL) {
             errno = ENOMEM;
             return 0;
         }
-        memset(*ctx, '\0', sizeof(LP_DIR_CTX));
+        memset(*ctx, '\0', sizeof(**ctx));
 
         (*ctx)->dir = opendir(directory);
         if ((*ctx)->dir == NULL) {
diff --git a/crypto/LPdir_vms.c b/crypto/LPdir_vms.c
index 88c7ddd..1e8f9e7 100644
--- a/crypto/LPdir_vms.c
+++ b/crypto/LPdir_vms.c
@@ -104,12 +104,12 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
             return 0;
         }
 
-        *ctx = (LP_DIR_CTX *)malloc(sizeof(LP_DIR_CTX));
+        *ctx = malloc(sizeof(**ctx));
         if (*ctx == NULL) {
             errno = ENOMEM;
             return 0;
         }
-        memset(*ctx, '\0', sizeof(LP_DIR_CTX));
+        memset(*ctx, '\0', sizeof(**ctx));
 
         strcpy((*ctx)->filespec, directory);
         strcat((*ctx)->filespec, "*.*;");
diff --git a/crypto/LPdir_win.c b/crypto/LPdir_win.c
index 07e63fb..78a796d 100644
--- a/crypto/LPdir_win.c
+++ b/crypto/LPdir_win.c
@@ -69,12 +69,12 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
             return 0;
         }
 
-        *ctx = (LP_DIR_CTX *)malloc(sizeof(LP_DIR_CTX));
+        *ctx = malloc(sizeof(**ctx));
         if (*ctx == NULL) {
             errno = ENOMEM;
             return 0;
         }
-        memset(*ctx, '\0', sizeof(LP_DIR_CTX));
+        memset(*ctx, '\0', sizeof(**ctx));
 
         if (directory[dirlen - 1] != '*') {
             extdirbuf = (char *)malloc(dirlen + 3);
diff --git a/crypto/asn1/a_object.c b/crypto/asn1/a_object.c
index 809e9a4..7cedce8 100644
--- a/crypto/asn1/a_object.c
+++ b/crypto/asn1/a_object.c
@@ -345,7 +345,7 @@ ASN1_OBJECT *ASN1_OBJECT_new(void)
 {
     ASN1_OBJECT *ret;
 
-    ret = OPENSSL_malloc(sizeof(ASN1_OBJECT));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (ret == NULL) {
         ASN1err(ASN1_F_ASN1_OBJECT_NEW, ERR_R_MALLOC_FAILURE);
         return (NULL);
diff --git a/crypto/asn1/a_strnid.c b/crypto/asn1/a_strnid.c
index 5126298..071613b 100644
--- a/crypto/asn1/a_strnid.c
+++ b/crypto/asn1/a_strnid.c
@@ -240,7 +240,7 @@ static ASN1_STRING_TABLE *stable_get(int nid)
     tmp = ASN1_STRING_TABLE_get(nid);
     if (tmp && tmp->flags & STABLE_FLAGS_MALLOC)
         return tmp;
-    rv = OPENSSL_malloc(sizeof(ASN1_STRING_TABLE));
+    rv = OPENSSL_malloc(sizeof(*rv));
     if (!rv)
         return NULL;
     if (!sk_ASN1_STRING_TABLE_push(stable, rv)) {
diff --git a/crypto/asn1/ameth_lib.c b/crypto/asn1/ameth_lib.c
index 49f4e5a..c7acb46 100644
--- a/crypto/asn1/ameth_lib.c
+++ b/crypto/asn1/ameth_lib.c
@@ -284,7 +284,7 @@ EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags,
                                         const char *pem_str, const char *info)
 {
     EVP_PKEY_ASN1_METHOD *ameth;
-    ameth = OPENSSL_malloc(sizeof(EVP_PKEY_ASN1_METHOD));
+    ameth = OPENSSL_malloc(sizeof(*ameth));
     if (!ameth)
         return NULL;
 
diff --git a/crypto/asn1/asn1_lib.c b/crypto/asn1/asn1_lib.c
index e1e509b..bda6ab0 100644
--- a/crypto/asn1/asn1_lib.c
+++ b/crypto/asn1/asn1_lib.c
@@ -349,7 +349,7 @@ ASN1_STRING *ASN1_STRING_type_new(int type)
 {
     ASN1_STRING *ret;
 
-    ret = OPENSSL_malloc(sizeof(ASN1_STRING));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (ret == NULL) {
         ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE);
         return (NULL);
diff --git a/crypto/asn1/asn_mime.c b/crypto/asn1/asn_mime.c
index e8411a8..da5b417 100644
--- a/crypto/asn1/asn_mime.c
+++ b/crypto/asn1/asn_mime.c
@@ -844,7 +844,7 @@ static MIME_HEADER *mime_hdr_new(char *name, char *value)
             }
         }
     }
-    mhdr = OPENSSL_malloc(sizeof(MIME_HEADER));
+    mhdr = OPENSSL_malloc(sizeof(*mhdr));
     if (!mhdr)
         goto err;
     mhdr->name = tmpname;
@@ -883,7 +883,7 @@ static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value)
             goto err;
     }
     /* Parameter values are case sensitive so leave as is */
-    mparam = OPENSSL_malloc(sizeof(MIME_PARAM));
+    mparam = OPENSSL_malloc(sizeof(*mparam));
     if (!mparam)
         goto err;
     mparam->param_name = tmpname;
diff --git a/crypto/asn1/bio_asn1.c b/crypto/asn1/bio_asn1.c
index ba39069..910d06f 100644
--- a/crypto/asn1/bio_asn1.c
+++ b/crypto/asn1/bio_asn1.c
@@ -146,7 +146,7 @@ BIO_METHOD *BIO_f_asn1(void)
 static int asn1_bio_new(BIO *b)
 {
     BIO_ASN1_BUF_CTX *ctx;
-    ctx = OPENSSL_malloc(sizeof(BIO_ASN1_BUF_CTX));
+    ctx = OPENSSL_malloc(sizeof(*ctx));
     if (!ctx)
         return 0;
     if (!asn1_bio_init(ctx, DEFAULT_ASN1_BUF_SIZE)) {
diff --git a/crypto/asn1/bio_ndef.c b/crypto/asn1/bio_ndef.c
index de517f2..ff2fdf5 100644
--- a/crypto/asn1/bio_ndef.c
+++ b/crypto/asn1/bio_ndef.c
@@ -106,7 +106,7 @@ BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it)
         ASN1err(ASN1_F_BIO_NEW_NDEF, ASN1_R_STREAMING_NOT_SUPPORTED);
         return NULL;
     }
-    ndef_aux = OPENSSL_malloc(sizeof(NDEF_SUPPORT));
+    ndef_aux = OPENSSL_malloc(sizeof(*ndef_aux));
     asn_bio = BIO_new(BIO_f_asn1());
 
     /* ASN1 bio needs to be next to output BIO */
diff --git a/crypto/asn1/tasn_new.c b/crypto/asn1/tasn_new.c
index aeced95..f54bd9b 100644
--- a/crypto/asn1/tasn_new.c
+++ b/crypto/asn1/tasn_new.c
@@ -319,7 +319,7 @@ static int asn1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
         return 1;
 
     case V_ASN1_ANY:
-        typ = OPENSSL_malloc(sizeof(ASN1_TYPE));
+        typ = OPENSSL_malloc(sizeof(*typ));
         if (!typ)
             return 0;
         typ->value.ptr = NULL;
diff --git a/crypto/asn1/tasn_prn.c b/crypto/asn1/tasn_prn.c
index 76d584b..e080e72 100644
--- a/crypto/asn1/tasn_prn.c
+++ b/crypto/asn1/tasn_prn.c
@@ -85,7 +85,7 @@ ASN1_PCTX default_pctx = {
 ASN1_PCTX *ASN1_PCTX_new(void)
 {
     ASN1_PCTX *ret;
-    ret = OPENSSL_malloc(sizeof(ASN1_PCTX));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (ret == NULL) {
         ASN1err(ASN1_F_ASN1_PCTX_NEW, ERR_R_MALLOC_FAILURE);
         return NULL;
diff --git a/crypto/asn1/tasn_scn.c b/crypto/asn1/tasn_scn.c
index cedea9c..43a125c 100644
--- a/crypto/asn1/tasn_scn.c
+++ b/crypto/asn1/tasn_scn.c
@@ -75,7 +75,7 @@
 ASN1_SCTX *ASN1_SCTX_new(int (*scan_cb) (ASN1_SCTX *ctx))
 {
     ASN1_SCTX *ret;
-    ret = OPENSSL_malloc(sizeof(ASN1_SCTX));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (ret == NULL) {
         ASN1err(ASN1_F_ASN1_SCTX_NEW, ERR_R_MALLOC_FAILURE);
         return NULL;
diff --git a/crypto/asn1/x_crl.c b/crypto/asn1/x_crl.c
index a32158b..0d759be 100644
--- a/crypto/asn1/x_crl.c
+++ b/crypto/asn1/x_crl.c
@@ -476,7 +476,7 @@ X509_CRL_METHOD *X509_CRL_METHOD_new(int (*crl_init) (X509_CRL *crl),
                                                         EVP_PKEY *pk))
 {
     X509_CRL_METHOD *m;
-    m = OPENSSL_malloc(sizeof(X509_CRL_METHOD));
+    m = OPENSSL_malloc(sizeof(*m));
     if (!m)
         return NULL;
     m->crl_init = crl_init;
diff --git a/crypto/asn1/x_info.c b/crypto/asn1/x_info.c
index 5b927ef..856bcf5 100644
--- a/crypto/asn1/x_info.c
+++ b/crypto/asn1/x_info.c
@@ -66,7 +66,7 @@ X509_INFO *X509_INFO_new(void)
 {
     X509_INFO *ret = NULL;
 
-    ret = OPENSSL_malloc(sizeof(X509_INFO));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (ret == NULL) {
         ASN1err(ASN1_F_X509_INFO_NEW, ERR_R_MALLOC_FAILURE);
         return (NULL);
diff --git a/crypto/asn1/x_pkey.c b/crypto/asn1/x_pkey.c
index 59e002b..b01616f 100644
--- a/crypto/asn1/x_pkey.c
+++ b/crypto/asn1/x_pkey.c
@@ -66,10 +66,10 @@ X509_PKEY *X509_PKEY_new(void)
 {
     X509_PKEY *ret = NULL;
 
-    ret = OPENSSL_malloc(sizeof(X509_PKEY));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (!ret)
         goto err;
-    memset(ret, 0, sizeof(X509_PKEY));
+    memset(ret, 0, sizeof(*ret));
 
     ret->version = 0;
     ret->enc_algor = X509_ALGOR_new();
diff --git a/crypto/bio/bf_buff.c b/crypto/bio/bf_buff.c
index 53a1204..6487f43 100644
--- a/crypto/bio/bf_buff.c
+++ b/crypto/bio/bf_buff.c
@@ -91,9 +91,8 @@ BIO_METHOD *BIO_f_buffer(void)
 
 static int buffer_new(BIO *bi)
 {
-    BIO_F_BUFFER_CTX *ctx;
+    BIO_F_BUFFER_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));
 
-    ctx = OPENSSL_malloc(sizeof(BIO_F_BUFFER_CTX));
     if (ctx == NULL)
         return (0);
     ctx->ibuf = OPENSSL_malloc(DEFAULT_BUFFER_SIZE);
diff --git a/crypto/bio/bf_lbuf.c b/crypto/bio/bf_lbuf.c
index d7906b4..e948e92 100644
--- a/crypto/bio/bf_lbuf.c
+++ b/crypto/bio/bf_lbuf.c
@@ -104,7 +104,7 @@ static int linebuffer_new(BIO *bi)
 {
     BIO_LINEBUFFER_CTX *ctx;
 
-    ctx = OPENSSL_malloc(sizeof(BIO_LINEBUFFER_CTX));
+    ctx = OPENSSL_malloc(sizeof(*ctx));
     if (ctx == NULL)
         return (0);
     ctx->obuf = OPENSSL_malloc(DEFAULT_LINEBUFFER_SIZE);
diff --git a/crypto/bio/bf_nbio.c b/crypto/bio/bf_nbio.c
index 9b9c0c0..53829dd 100644
--- a/crypto/bio/bf_nbio.c
+++ b/crypto/bio/bf_nbio.c
@@ -102,7 +102,7 @@ static int nbiof_new(BIO *bi)
 {
     NBIO_TEST *nt;
 
-    if (!(nt = OPENSSL_malloc(sizeof(NBIO_TEST))))
+    if (!(nt = OPENSSL_malloc(sizeof(*nt))))
         return (0);
     nt->lrn = -1;
     nt->lwn = -1;
diff --git a/crypto/bio/bio_lib.c b/crypto/bio/bio_lib.c
index e7957a7..7542d1c 100644
--- a/crypto/bio/bio_lib.c
+++ b/crypto/bio/bio_lib.c
@@ -65,9 +65,8 @@
 
 BIO *BIO_new(BIO_METHOD *method)
 {
-    BIO *ret = NULL;
+    BIO *ret = OPENSSL_malloc(sizeof(*ret));
 
-    ret = OPENSSL_malloc(sizeof(BIO));
     if (ret == NULL) {
         BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE);
         return (NULL);
diff --git a/crypto/bio/bss_acpt.c b/crypto/bio/bss_acpt.c
index 6793fe1..cde8da3 100644
--- a/crypto/bio/bss_acpt.c
+++ b/crypto/bio/bss_acpt.c
@@ -137,7 +137,7 @@ static BIO_ACCEPT *BIO_ACCEPT_new(void)
 {
     BIO_ACCEPT *ret;
 
-    if ((ret = OPENSSL_malloc(sizeof(BIO_ACCEPT))) == NULL)
+    if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
         return (NULL);
 
     memset(ret, 0, sizeof(BIO_ACCEPT));
diff --git a/crypto/bio/bss_bio.c b/crypto/bio/bss_bio.c
index c9b8e7f..afd2107 100644
--- a/crypto/bio/bss_bio.c
+++ b/crypto/bio/bss_bio.c
@@ -144,7 +144,7 @@ static int bio_new(BIO *bio)
 {
     struct bio_bio_st *b;
 
-    b = OPENSSL_malloc(sizeof *b);
+    b = OPENSSL_malloc(sizeof(*b));
     if (b == NULL)
         return 0;
 
diff --git a/crypto/bio/bss_conn.c b/crypto/bio/bss_conn.c
index 0b82082..b8fa828 100644
--- a/crypto/bio/bss_conn.c
+++ b/crypto/bio/bss_conn.c
@@ -286,7 +286,7 @@ BIO_CONNECT *BIO_CONNECT_new(void)
 {
     BIO_CONNECT *ret;
 
-    if ((ret = OPENSSL_malloc(sizeof(BIO_CONNECT))) == NULL)
+    if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
         return (NULL);
     ret->state = BIO_CONN_S_BEFORE;
     ret->param_hostname = NULL;
diff --git a/crypto/bio/bss_dgram.c b/crypto/bio/bss_dgram.c
index 406d46b..fb1564c 100644
--- a/crypto/bio/bss_dgram.c
+++ b/crypto/bio/bss_dgram.c
@@ -225,7 +225,7 @@ static int dgram_new(BIO *bi)
 
     bi->init = 0;
     bi->num = 0;
-    data = OPENSSL_malloc(sizeof(bio_dgram_data));
+    data = OPENSSL_malloc(sizeof(*data));
     if (data == NULL)
         return 0;
     memset(data, 0x00, sizeof(bio_dgram_data));
@@ -1085,7 +1085,7 @@ static int dgram_sctp_new(BIO *bi)
 
     bi->init = 0;
     bi->num = 0;
-    data = OPENSSL_malloc(sizeof(bio_dgram_sctp_data));
+    data = OPENSSL_malloc(sizeof(*data));
     if (data == NULL)
         return 0;
     memset(data, 0x00, sizeof(bio_dgram_sctp_data));
diff --git a/crypto/bn/Makefile b/crypto/bn/Makefile
index 5b45f11..2bae4ab 100644
--- a/crypto/bn/Makefile
+++ b/crypto/bn/Makefile
@@ -215,7 +215,7 @@ bn_depr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
 bn_depr.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
 bn_depr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
 bn_depr.o: ../cryptlib.h ../include/internal/bn_int.h bn_depr.c bn_lcl.h
-bn_dh.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
+bn_dh.o: ../../e_os.h ../../include/openssl/bn.h ../../include/openssl/crypto.h
 bn_dh.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
 bn_dh.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
 bn_dh.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
@@ -391,12 +391,12 @@ bn_sqrt.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
 bn_sqrt.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
 bn_sqrt.o: ../../include/openssl/symhacks.h ../cryptlib.h
 bn_sqrt.o: ../include/internal/bn_int.h bn_lcl.h bn_sqrt.c
-bn_srp.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
-bn_srp.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
-bn_srp.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
-bn_srp.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
-bn_srp.o: ../../include/openssl/symhacks.h ../include/internal/bn_int.h
-bn_srp.o: bn_lcl.h bn_srp.c
+bn_srp.o: ../../e_os.h ../../include/openssl/bn.h
+bn_srp.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
+bn_srp.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
+bn_srp.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
+bn_srp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
+bn_srp.o: ../include/internal/bn_int.h bn_lcl.h bn_srp.c
 bn_word.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
 bn_word.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
 bn_word.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
diff --git a/crypto/bn/bn_blind.c b/crypto/bn/bn_blind.c
index 659638b..9338cdd 100644
--- a/crypto/bn/bn_blind.c
+++ b/crypto/bn/bn_blind.c
@@ -137,7 +137,7 @@ BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod)
 
     bn_check_top(mod);
 
-    if ((ret = OPENSSL_malloc(sizeof(BN_BLINDING))) == NULL) {
+    if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) {
         BNerr(BN_F_BN_BLINDING_NEW, ERR_R_MALLOC_FAILURE);
         return (NULL);
     }
diff --git a/crypto/bn/bn_ctx.c b/crypto/bn/bn_ctx.c
index d2dd1e6..481c9d2 100644
--- a/crypto/bn/bn_ctx.c
+++ b/crypto/bn/bn_ctx.c
@@ -186,7 +186,7 @@ static void ctxdbg(BN_CTX *ctx)
 
 BN_CTX *BN_CTX_new(void)
 {
-    BN_CTX *ret = OPENSSL_malloc(sizeof(BN_CTX));
+    BN_CTX *ret = OPENSSL_malloc(sizeof(*ret));
     if (!ret) {
         BNerr(BN_F_BN_CTX_NEW, ERR_R_MALLOC_FAILURE);
         return NULL;
@@ -353,7 +353,7 @@ static BIGNUM *BN_POOL_get(BN_POOL *p)
     if (p->used == p->size) {
         BIGNUM *bn;
         unsigned int loop = 0;
-        BN_POOL_ITEM *item = OPENSSL_malloc(sizeof(BN_POOL_ITEM));
+        BN_POOL_ITEM *item = OPENSSL_malloc(sizeof(*item));
         if (!item)
             return NULL;
         /* Initialise the structure */
diff --git a/crypto/bn/bn_gf2m.c b/crypto/bn/bn_gf2m.c
index c87c5d9..50d7c74 100644
--- a/crypto/bn/bn_gf2m.c
+++ b/crypto/bn/bn_gf2m.c
@@ -551,7 +551,7 @@ int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
     bn_check_top(a);
     bn_check_top(b);
     bn_check_top(p);
-    if ((arr = OPENSSL_malloc(sizeof(int) * max)) == NULL)
+    if ((arr = OPENSSL_malloc(sizeof(*arr) * max)) == NULL)
         goto err;
     ret = BN_GF2m_poly2arr(p, arr, max);
     if (!ret || ret > max) {
@@ -609,7 +609,7 @@ int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
 
     bn_check_top(a);
     bn_check_top(p);
-    if ((arr = OPENSSL_malloc(sizeof(int) * max)) == NULL)
+    if ((arr = OPENSSL_malloc(sizeof(*arr) * max)) == NULL)
         goto err;
     ret = BN_GF2m_poly2arr(p, arr, max);
     if (!ret || ret > max) {
@@ -1025,7 +1025,7 @@ int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
     bn_check_top(a);
     bn_check_top(b);
     bn_check_top(p);
-    if ((arr = OPENSSL_malloc(sizeof(int) * max)) == NULL)
+    if ((arr = OPENSSL_malloc(sizeof(*arr) * max)) == NULL)
         goto err;
     ret = BN_GF2m_poly2arr(p, arr, max);
     if (!ret || ret > max) {
@@ -1084,7 +1084,7 @@ int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
     int *arr = NULL;
     bn_check_top(a);
     bn_check_top(p);
-    if ((arr = OPENSSL_malloc(sizeof(int) * max)) == NULL)
+    if ((arr = OPENSSL_malloc(sizeof(*arr) * max)) == NULL)
         goto err;
     ret = BN_GF2m_poly2arr(p, arr, max);
     if (!ret || ret > max) {
@@ -1214,7 +1214,7 @@ int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
     int *arr = NULL;
     bn_check_top(a);
     bn_check_top(p);
-    if ((arr = OPENSSL_malloc(sizeof(int) * max)) == NULL)
+    if ((arr = OPENSSL_malloc(sizeof(*arr) * max)) == NULL)
         goto err;
     ret = BN_GF2m_poly2arr(p, arr, max);
     if (!ret || ret > max) {
diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c
index 3e9ea8e..6fc0e39 100644
--- a/crypto/bn/bn_lib.c
+++ b/crypto/bn/bn_lib.c
@@ -268,7 +268,7 @@ BIGNUM *BN_new(void)
 {
     BIGNUM *ret;
 
-    if ((ret = OPENSSL_malloc(sizeof(BIGNUM))) == NULL) {
+    if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) {
         BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE);
         return (NULL);
     }
@@ -299,7 +299,7 @@ static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
         BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_EXPAND_ON_STATIC_BIGNUM_DATA);
         return (NULL);
     }
-    a = A = OPENSSL_malloc(sizeof(BN_ULONG) * words);
+    a = A = OPENSSL_malloc(sizeof(*a) * words);
     if (A == NULL) {
         BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE);
         return (NULL);
@@ -919,7 +919,7 @@ BN_GENCB *BN_GENCB_new(void)
 {
     BN_GENCB *ret;
 
-    if ((ret = OPENSSL_malloc(sizeof(BN_GENCB))) == NULL) {
+    if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) {
         BNerr(BN_F_BN_GENCB_NEW, ERR_R_MALLOC_FAILURE);
         return (NULL);
     }
diff --git a/crypto/bn/bn_mont.c b/crypto/bn/bn_mont.c
index f19910d..d07afcc 100644
--- a/crypto/bn/bn_mont.c
+++ b/crypto/bn/bn_mont.c
@@ -314,7 +314,7 @@ BN_MONT_CTX *BN_MONT_CTX_new(void)
 {
     BN_MONT_CTX *ret;
 
-    if ((ret = OPENSSL_malloc(sizeof(BN_MONT_CTX))) == NULL)
+    if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
         return (NULL);
 
     BN_MONT_CTX_init(ret);
diff --git a/crypto/bn/bn_recp.c b/crypto/bn/bn_recp.c
index ef1972b..3ab486b 100644
--- a/crypto/bn/bn_recp.c
+++ b/crypto/bn/bn_recp.c
@@ -71,7 +71,7 @@ BN_RECP_CTX *BN_RECP_CTX_new(void)
 {
     BN_RECP_CTX *ret;
 
-    if ((ret = OPENSSL_malloc(sizeof(BN_RECP_CTX))) == NULL)
+    if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
         return (NULL);
 
     BN_RECP_CTX_init(ret);
diff --git a/crypto/buffer/buffer.c b/crypto/buffer/buffer.c
index c77fdc5..b41b8f2 100644
--- a/crypto/buffer/buffer.c
+++ b/crypto/buffer/buffer.c
@@ -71,7 +71,7 @@ BUF_MEM *BUF_MEM_new(void)
 {
     BUF_MEM *ret;
 
-    ret = OPENSSL_malloc(sizeof(BUF_MEM));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (ret == NULL) {
         BUFerr(BUF_F_BUF_MEM_NEW, ERR_R_MALLOC_FAILURE);
         return (NULL);
diff --git a/crypto/cmac/cmac.c b/crypto/cmac/cmac.c
index 5e8fdc3..e7db320 100644
--- a/crypto/cmac/cmac.c
+++ b/crypto/cmac/cmac.c
@@ -90,7 +90,8 @@ static void make_kn(unsigned char *k1, const unsigned char *l, int bl)
 CMAC_CTX *CMAC_CTX_new(void)
 {
     CMAC_CTX *ctx;
-    ctx = OPENSSL_malloc(sizeof(CMAC_CTX));
+
+    ctx = OPENSSL_malloc(sizeof(*ctx));
     if (!ctx)
         return NULL;
     EVP_CIPHER_CTX_init(&ctx->cctx);
diff --git a/crypto/comp/c_zlib.c b/crypto/comp/c_zlib.c
index 334c78f..2d5b54f 100644
--- a/crypto/comp/c_zlib.c
+++ b/crypto/comp/c_zlib.c
@@ -119,7 +119,7 @@ static int zlib_stateful_ex_idx = -1;
 static int zlib_stateful_init(COMP_CTX *ctx)
 {
     int err;
-    struct zlib_state *state = OPENSSL_malloc(sizeof(struct zlib_state));
+    struct zlib_state *state = OPENSSL_malloc(sizeof(*state));
 
     if (state == NULL)
         goto err;
@@ -347,7 +347,7 @@ static int bio_zlib_new(BIO *bi)
         return 0;
     }
 # endif
-    ctx = OPENSSL_malloc(sizeof(BIO_ZLIB_CTX));
+    ctx = OPENSSL_malloc(sizeof(*ctx));
     if (!ctx) {
         COMPerr(COMP_F_BIO_ZLIB_NEW, ERR_R_MALLOC_FAILURE);
         return 0;
diff --git a/crypto/comp/comp_lib.c b/crypto/comp/comp_lib.c
index 7bcdd6b..9feb0af 100644
--- a/crypto/comp/comp_lib.c
+++ b/crypto/comp/comp_lib.c
@@ -8,7 +8,7 @@ COMP_CTX *COMP_CTX_new(COMP_METHOD *meth)
 {
     COMP_CTX *ret;
 
-    if ((ret = OPENSSL_malloc(sizeof(COMP_CTX))) == NULL) {
+    if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) {
         /* ZZZZZZZZZZZZZZZZ */
         return (NULL);
     }
diff --git a/crypto/conf/conf_api.c b/crypto/conf/conf_api.c
index 59808a3..3badf7f 100644
--- a/crypto/conf/conf_api.c
+++ b/crypto/conf/conf_api.c
@@ -255,7 +255,7 @@ CONF_VALUE *_CONF_new_section(CONF *conf, const char *section)
 
     if ((sk = sk_CONF_VALUE_new_null()) == NULL)
         goto err;
-    if ((v = OPENSSL_malloc(sizeof(CONF_VALUE))) == NULL)
+    if ((v = OPENSSL_malloc(sizeof(*v))) == NULL)
         goto err;
     i = strlen(section) + 1;
     if ((v->section = OPENSSL_malloc(i)) == NULL)
diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c
index 0ed06e1..8af2ab1 100644
--- a/crypto/conf/conf_def.c
+++ b/crypto/conf/conf_def.c
@@ -130,7 +130,7 @@ static CONF *def_create(CONF_METHOD *meth)
 {
     CONF *ret;
 
-    ret = OPENSSL_malloc(sizeof(CONF) + sizeof(unsigned short *));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (ret)
         if (meth->init(ret) == 0) {
             OPENSSL_free(ret);
@@ -357,7 +357,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
             p++;
             *p = '\0';
 
-            if (!(v = OPENSSL_malloc(sizeof(CONF_VALUE)))) {
+            if (!(v = OPENSSL_malloc(sizeof(*v)))) {
                 CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
                 goto err;
             }
diff --git a/crypto/conf/conf_mod.c b/crypto/conf/conf_mod.c
index 18fe38b..23d2a58 100644
--- a/crypto/conf/conf_mod.c
+++ b/crypto/conf/conf_mod.c
@@ -281,7 +281,7 @@ static CONF_MODULE *module_add(DSO *dso, const char *name,
         supported_modules = sk_CONF_MODULE_new_null();
     if (supported_modules == NULL)
         return NULL;
-    tmod = OPENSSL_malloc(sizeof(CONF_MODULE));
+    tmod = OPENSSL_malloc(sizeof(*tmod));
     if (tmod == NULL)
         return NULL;
 
@@ -336,7 +336,7 @@ static int module_init(CONF_MODULE *pmod, char *name, char *value,
     CONF_IMODULE *imod = NULL;
 
     /* Otherwise add initialized module to list */
-    imod = OPENSSL_malloc(sizeof(CONF_IMODULE));
+    imod = OPENSSL_malloc(sizeof(*imod));
     if (!imod)
         goto err;
 
diff --git a/crypto/dh/dh_lib.c b/crypto/dh/dh_lib.c
index 10e98c6..1ae081c 100644
--- a/crypto/dh/dh_lib.c
+++ b/crypto/dh/dh_lib.c
@@ -109,7 +109,7 @@ DH *DH_new(void)
 
 DH *DH_new_method(ENGINE *engine)
 {
-    DH *ret = OPENSSL_malloc(sizeof(DH));
+    DH *ret = OPENSSL_malloc(sizeof(*ret));
 
     if (ret == NULL) {
         DHerr(DH_F_DH_NEW_METHOD, ERR_R_MALLOC_FAILURE);
diff --git a/crypto/dh/dh_pmeth.c b/crypto/dh/dh_pmeth.c
index be44c0b..1e10364 100644
--- a/crypto/dh/dh_pmeth.c
+++ b/crypto/dh/dh_pmeth.c
@@ -98,7 +98,7 @@ typedef struct {
 static int pkey_dh_init(EVP_PKEY_CTX *ctx)
 {
     DH_PKEY_CTX *dctx;
-    dctx = OPENSSL_malloc(sizeof(DH_PKEY_CTX));
+    dctx = OPENSSL_malloc(sizeof(*dctx));
     if (!dctx)
         return 0;
     dctx->prime_len = 1024;
diff --git a/crypto/dsa/dsa_asn1.c b/crypto/dsa/dsa_asn1.c
index d79f261..0f0c515 100644
--- a/crypto/dsa/dsa_asn1.c
+++ b/crypto/dsa/dsa_asn1.c
@@ -70,7 +70,7 @@ static int sig_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
 {
     if (operation == ASN1_OP_NEW_PRE) {
         DSA_SIG *sig;
-        sig = OPENSSL_malloc(sizeof(DSA_SIG));
+        sig = OPENSSL_malloc(sizeof(*sig));
         if (!sig) {
             DSAerr(DSA_F_SIG_CB, ERR_R_MALLOC_FAILURE);
             return 0;
diff --git a/crypto/dsa/dsa_lib.c b/crypto/dsa/dsa_lib.c
index aec1b36..2a193c8 100644
--- a/crypto/dsa/dsa_lib.c
+++ b/crypto/dsa/dsa_lib.c
@@ -117,7 +117,7 @@ DSA *DSA_new_method(ENGINE *engine)
 {
     DSA *ret;
 
-    ret = OPENSSL_malloc(sizeof(DSA));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (ret == NULL) {
         DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_MALLOC_FAILURE);
         return (NULL);
diff --git a/crypto/dsa/dsa_pmeth.c b/crypto/dsa/dsa_pmeth.c
index 7aa1054..853612a 100644
--- a/crypto/dsa/dsa_pmeth.c
+++ b/crypto/dsa/dsa_pmeth.c
@@ -81,7 +81,7 @@ typedef struct {
 static int pkey_dsa_init(EVP_PKEY_CTX *ctx)
 {
     DSA_PKEY_CTX *dctx;
-    dctx = OPENSSL_malloc(sizeof(DSA_PKEY_CTX));
+    dctx = OPENSSL_malloc(sizeof(*dctx));
     if (!dctx)
         return 0;
     dctx->nbits = 1024;
diff --git a/crypto/dso/dso_lib.c b/crypto/dso/dso_lib.c
index 99701d1..a0e711c 100644
--- a/crypto/dso/dso_lib.c
+++ b/crypto/dso/dso_lib.c
@@ -104,7 +104,7 @@ DSO *DSO_new_method(DSO_METHOD *meth)
          */
         default_DSO_meth = DSO_METHOD_openssl();
     }
-    ret = OPENSSL_malloc(sizeof(DSO));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (ret == NULL) {
         DSOerr(DSO_F_DSO_NEW_METHOD, ERR_R_MALLOC_FAILURE);
         return (NULL);
diff --git a/crypto/dso/dso_vms.c b/crypto/dso/dso_vms.c
index 821e238..07ec1cd 100644
--- a/crypto/dso/dso_vms.c
+++ b/crypto/dso/dso_vms.c
@@ -230,7 +230,7 @@ static int vms_load(DSO *dso)
         goto err;
     }
 
-    p = DSO_MALLOC(sizeof(DSO_VMS_INTERNAL));
+    p = DSO_MALLOC(sizeof(*p));
     if (p == NULL) {
         DSOerr(DSO_F_VMS_LOAD, ERR_R_MALLOC_FAILURE);
         goto err;
diff --git a/crypto/dso/dso_win32.c b/crypto/dso/dso_win32.c
index 144d8e6..bd96c5d 100644
--- a/crypto/dso/dso_win32.c
+++ b/crypto/dso/dso_win32.c
@@ -168,7 +168,7 @@ static int win32_load(DSO *dso)
         ERR_add_error_data(3, "filename(", filename, ")");
         goto err;
     }
-    p = OPENSSL_malloc(sizeof(HINSTANCE));
+    p = OPENSSL_malloc(sizeof(*p));
     if (p == NULL) {
         DSOerr(DSO_F_WIN32_LOAD, ERR_R_MALLOC_FAILURE);
         goto err;
@@ -304,7 +304,7 @@ static struct file_st *win32_splitter(DSO *dso, const char *filename,
         return (NULL);
     }
 
-    result = OPENSSL_malloc(sizeof(struct file_st));
+    result = OPENSSL_malloc(sizeof(*result));
     if (result == NULL) {
         DSOerr(DSO_F_WIN32_SPLITTER, ERR_R_MALLOC_FAILURE);
         return (NULL);
diff --git a/crypto/ec/Makefile b/crypto/ec/Makefile
index 423f60b..ec17b3f 100644
--- a/crypto/ec/Makefile
+++ b/crypto/ec/Makefile
@@ -143,11 +143,12 @@ ec_check.o: ../../include/openssl/obj_mac.h ../../include/openssl/opensslconf.h
 ec_check.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
 ec_check.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
 ec_check.o: ../../include/openssl/symhacks.h ec_check.c ec_lcl.h
-ec_curve.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
-ec_curve.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
-ec_curve.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
-ec_curve.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
-ec_curve.o: ../../include/openssl/obj_mac.h ../../include/openssl/opensslconf.h
+ec_curve.o: ../../e_os.h ../../include/openssl/asn1.h
+ec_curve.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
+ec_curve.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
+ec_curve.o: ../../include/openssl/ec.h ../../include/openssl/err.h
+ec_curve.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
+ec_curve.o: ../../include/openssl/opensslconf.h
 ec_curve.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
 ec_curve.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
 ec_curve.o: ../../include/openssl/symhacks.h ec_curve.c ec_lcl.h
diff --git a/crypto/ec/ec_key.c b/crypto/ec/ec_key.c
index 4c588e8..07c33fe 100644
--- a/crypto/ec/ec_key.c
+++ b/crypto/ec/ec_key.c
@@ -67,9 +67,8 @@
 
 EC_KEY *EC_KEY_new(void)
 {
-    EC_KEY *ret;
+    EC_KEY *ret = OPENSSL_malloc(sizeof(*ret));
 
-    ret = OPENSSL_malloc(sizeof(EC_KEY));
     if (ret == NULL) {
         ECerr(EC_F_EC_KEY_NEW, ERR_R_MALLOC_FAILURE);
         return (NULL);
diff --git a/crypto/ec/ec_lib.c b/crypto/ec/ec_lib.c
index 628e879..9156943 100644
--- a/crypto/ec/ec_lib.c
+++ b/crypto/ec/ec_lib.c
@@ -85,7 +85,7 @@ EC_GROUP *EC_GROUP_new(const EC_METHOD *meth)
         return NULL;
     }
 
-    ret = OPENSSL_malloc(sizeof *ret);
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (ret == NULL) {
         ECerr(EC_F_EC_GROUP_NEW, ERR_R_MALLOC_FAILURE);
         return NULL;
@@ -158,7 +158,7 @@ void EC_GROUP_clear_free(EC_GROUP *group)
     BN_clear_free(group->order);
     BN_clear_free(group->cofactor);
     OPENSSL_clear_free(group->seed, group->seed_len);
-    OPENSSL_clear_free(group, sizeof *group);
+    OPENSSL_clear_free(group, sizeof(*group));
 }
 
 int EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src)
@@ -555,7 +555,7 @@ int EC_EX_DATA_set_data(EC_EXTRA_DATA **ex_data, void *data,
         /* no explicit entry needed */
         return 1;
 
-    d = OPENSSL_malloc(sizeof *d);
+    d = OPENSSL_malloc(sizeof(*d));
     if (d == NULL)
         return 0;
 
@@ -692,7 +692,7 @@ EC_POINT *EC_POINT_new(const EC_GROUP *group)
         return NULL;
     }
 
-    ret = OPENSSL_malloc(sizeof *ret);
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (ret == NULL) {
         ECerr(EC_F_EC_POINT_NEW, ERR_R_MALLOC_FAILURE);
         return NULL;
@@ -727,7 +727,7 @@ void EC_POINT_clear_free(EC_POINT *point)
         point->meth->point_clear_finish(point);
     else if (point->meth->point_finish != 0)
         point->meth->point_finish(point);
-    OPENSSL_clear_free(point, sizeof *point);
+    OPENSSL_clear_free(point, sizeof(*point));
 }
 
 int EC_POINT_copy(EC_POINT *dest, const EC_POINT *src)
diff --git a/crypto/ec/ec_mult.c b/crypto/ec/ec_mult.c
index bd99c82..9b75b9b 100644
--- a/crypto/ec/ec_mult.c
+++ b/crypto/ec/ec_mult.c
@@ -100,7 +100,7 @@ static EC_PRE_COMP *ec_pre_comp_new(const EC_GROUP *group)
     if (!group)
         return NULL;
 
-    ret = OPENSSL_malloc(sizeof(EC_PRE_COMP));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (!ret) {
         ECerr(EC_F_EC_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);
         return ret;
@@ -165,11 +165,11 @@ static void ec_pre_comp_clear_free(void *pre_)
 
         for (p = pre->points; *p != NULL; p++) {
             EC_POINT_clear_free(*p);
-            OPENSSL_cleanse(p, sizeof *p);
+            OPENSSL_cleanse(p, sizeof(*p));
         }
         OPENSSL_free(pre->points);
     }
-    OPENSSL_clear_free(pre, sizeof *pre);
+    OPENSSL_clear_free(pre, sizeof(*pre));
 }
 
 /*
@@ -659,7 +659,7 @@ int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
     num = pre_points_per_block * numblocks; /* number of points to compute
                                              * and store */
 
-    points = OPENSSL_malloc(sizeof(EC_POINT *) * (num + 1));
+    points = OPENSSL_malloc(sizeof(*points) * (num + 1));
     if (!points) {
         ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_MALLOC_FAILURE);
         goto err;
diff --git a/crypto/ec/ec_pmeth.c b/crypto/ec/ec_pmeth.c
index ec27e23..3fbeac5 100644
--- a/crypto/ec/ec_pmeth.c
+++ b/crypto/ec/ec_pmeth.c
@@ -91,7 +91,8 @@ typedef struct {
 static int pkey_ec_init(EVP_PKEY_CTX *ctx)
 {
     EC_PKEY_CTX *dctx;
-    dctx = OPENSSL_malloc(sizeof(EC_PKEY_CTX));
+
+    dctx = OPENSSL_malloc(sizeof(*dctx));
     if (!dctx)
         return 0;
     dctx->gen_group = NULL;
diff --git a/crypto/ec/ecp_nistp224.c b/crypto/ec/ecp_nistp224.c
index 60a8d50..c79e6da 100644
--- a/crypto/ec/ecp_nistp224.c
+++ b/crypto/ec/ecp_nistp224.c
@@ -1200,7 +1200,7 @@ static void batch_mul(felem x_out, felem y_out, felem z_out,
 static NISTP224_PRE_COMP *nistp224_pre_comp_new()
 {
     NISTP224_PRE_COMP *ret = NULL;
-    ret = OPENSSL_malloc(sizeof *ret);
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (!ret) {
         ECerr(EC_F_NISTP224_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);
         return ret;
@@ -1247,7 +1247,7 @@ static void nistp224_pre_comp_clear_free(void *pre_)
     if (i > 0)
         return;
 
-    OPENSSL_clear_free(pre, sizeof *pre);
+    OPENSSL_clear_free(pre, sizeof(*pre));
 }
 
 /******************************************************************************/
diff --git a/crypto/ec/ecp_nistp256.c b/crypto/ec/ecp_nistp256.c
index c9f073b..6ec5692 100644
--- a/crypto/ec/ecp_nistp256.c
+++ b/crypto/ec/ecp_nistp256.c
@@ -1815,7 +1815,7 @@ const EC_METHOD *EC_GFp_nistp256_method(void)
 static NISTP256_PRE_COMP *nistp256_pre_comp_new()
 {
     NISTP256_PRE_COMP *ret = NULL;
-    ret = OPENSSL_malloc(sizeof *ret);
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (!ret) {
         ECerr(EC_F_NISTP256_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);
         return ret;
@@ -1862,7 +1862,7 @@ static void nistp256_pre_comp_clear_free(void *pre_)
     if (i > 0)
         return;
 
-    OPENSSL_clear_free(pre, sizeof *pre);
+    OPENSSL_clear_free(pre, sizeof(*pre));
 }
 
 /******************************************************************************/
diff --git a/crypto/ec/ecp_nistp521.c b/crypto/ec/ecp_nistp521.c
index bdfd576..e208a83 100644
--- a/crypto/ec/ecp_nistp521.c
+++ b/crypto/ec/ecp_nistp521.c
@@ -1643,8 +1643,8 @@ const EC_METHOD *EC_GFp_nistp521_method(void)
 
 static NISTP521_PRE_COMP *nistp521_pre_comp_new()
 {
-    NISTP521_PRE_COMP *ret = NULL;
-    ret = OPENSSL_malloc(sizeof(NISTP521_PRE_COMP));
+    NISTP521_PRE_COMP *ret = OPENSSL_malloc(sizeof(*ret));
+
     if (!ret) {
         ECerr(EC_F_NISTP521_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);
         return ret;
diff --git a/crypto/ec/ecp_nistz256.c b/crypto/ec/ecp_nistz256.c
index e73d26c..83f0c6f 100644
--- a/crypto/ec/ecp_nistz256.c
+++ b/crypto/ec/ecp_nistz256.c
@@ -1408,7 +1408,7 @@ static EC_PRE_COMP *ecp_nistz256_pre_comp_new(const EC_GROUP *group)
     if (!group)
         return NULL;
 
-    ret = OPENSSL_malloc(sizeof(EC_PRE_COMP));
+    ret = OPENSSL_malloc(sizeof(*ret));
 
     if (!ret) {
         ECerr(EC_F_ECP_NISTZ256_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);
@@ -1463,7 +1463,7 @@ static void ecp_nistz256_pre_comp_clear_free(void *pre_)
 
     OPENSSL_clear_free(pre->precomp,
                        32 * sizeof(unsigned char) * (1 << pre->w) * 2 * 37);
-    OPENSSL_clear_free(pre, sizeof *pre);
+    OPENSSL_clear_free(pre, sizeof(*pre));
 }
 
 static int ecp_nistz256_window_have_precompute_mult(const EC_GROUP *group)
diff --git a/crypto/ecdh/ech_lib.c b/crypto/ecdh/ech_lib.c
index 82f8850..62734bc 100644
--- a/crypto/ecdh/ech_lib.c
+++ b/crypto/ecdh/ech_lib.c
@@ -117,7 +117,7 @@ static ECDH_DATA *ECDH_DATA_new_method(ENGINE *engine)
 {
     ECDH_DATA *ret;
 
-    ret = OPENSSL_malloc(sizeof(ECDH_DATA));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (ret == NULL) {
         ECDHerr(ECDH_F_ECDH_DATA_NEW_METHOD, ERR_R_MALLOC_FAILURE);
         return (NULL);
diff --git a/crypto/ecdsa/ecs_lib.c b/crypto/ecdsa/ecs_lib.c
index 3d01212..cabf6ec 100644
--- a/crypto/ecdsa/ecs_lib.c
+++ b/crypto/ecdsa/ecs_lib.c
@@ -105,7 +105,7 @@ static ECDSA_DATA *ECDSA_DATA_new_method(ENGINE *engine)
 {
     ECDSA_DATA *ret;
 
-    ret = OPENSSL_malloc(sizeof(ECDSA_DATA));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (ret == NULL) {
         ECDSAerr(ECDSA_F_ECDSA_DATA_NEW_METHOD, ERR_R_MALLOC_FAILURE);
         return (NULL);
@@ -253,7 +253,7 @@ ECDSA_METHOD *ECDSA_METHOD_new(ECDSA_METHOD *ecdsa_meth)
 {
     ECDSA_METHOD *ret;
 
-    ret = OPENSSL_malloc(sizeof(ECDSA_METHOD));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (ret == NULL) {
         ECDSAerr(ECDSA_F_ECDSA_METHOD_NEW, ERR_R_MALLOC_FAILURE);
         return NULL;
diff --git a/crypto/engine/eng_dyn.c b/crypto/engine/eng_dyn.c
index 84d8e86..ed1c220 100644
--- a/crypto/engine/eng_dyn.c
+++ b/crypto/engine/eng_dyn.c
@@ -202,8 +202,8 @@ static void dynamic_data_ctx_free_func(void *parent, void *ptr,
  */
 static int dynamic_set_data_ctx(ENGINE *e, dynamic_data_ctx **ctx)
 {
-    dynamic_data_ctx *c;
-    c = OPENSSL_malloc(sizeof(dynamic_data_ctx));
+    dynamic_data_ctx *c = OPENSSL_malloc(sizeof(*c));
+
     if (!c) {
         ENGINEerr(ENGINE_F_DYNAMIC_SET_DATA_CTX, ERR_R_MALLOC_FAILURE);
         return 0;
diff --git a/crypto/engine/eng_lib.c b/crypto/engine/eng_lib.c
index 64b0cad..3bf06bb 100644
--- a/crypto/engine/eng_lib.c
+++ b/crypto/engine/eng_lib.c
@@ -66,7 +66,7 @@ ENGINE *ENGINE_new(void)
 {
     ENGINE *ret;
 
-    ret = OPENSSL_malloc(sizeof(ENGINE));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (ret == NULL) {
         ENGINEerr(ENGINE_F_ENGINE_NEW, ERR_R_MALLOC_FAILURE);
         return NULL;
@@ -163,7 +163,7 @@ static int int_cleanup_check(int create)
 
 static ENGINE_CLEANUP_ITEM *int_cleanup_item(ENGINE_CLEANUP_CB *cb)
 {
-    ENGINE_CLEANUP_ITEM *item = OPENSSL_malloc(sizeof(ENGINE_CLEANUP_ITEM));
+    ENGINE_CLEANUP_ITEM *item = OPENSSL_malloc(sizeof(*item));
     if (!item)
         return NULL;
     item->cb = cb;
diff --git a/crypto/engine/eng_openssl.c b/crypto/engine/eng_openssl.c
index cc91044..e9bdd01 100644
--- a/crypto/engine/eng_openssl.c
+++ b/crypto/engine/eng_openssl.c
@@ -425,7 +425,7 @@ typedef struct {
 static int ossl_hmac_init(EVP_PKEY_CTX *ctx)
 {
     OSSL_HMAC_PKEY_CTX *hctx;
-    hctx = OPENSSL_malloc(sizeof(OSSL_HMAC_PKEY_CTX));
+    hctx = OPENSSL_malloc(sizeof(*hctx));
     if (!hctx)
         return 0;
     hctx->md = NULL;
diff --git a/crypto/engine/eng_table.c b/crypto/engine/eng_table.c
index 16eb771..f0f4dbb 100644
--- a/crypto/engine/eng_table.c
+++ b/crypto/engine/eng_table.c
@@ -147,7 +147,7 @@ int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
         tmplate.nid = *nids;
         fnd = lh_ENGINE_PILE_retrieve(&(*table)->piles, &tmplate);
         if (!fnd) {
-            fnd = OPENSSL_malloc(sizeof(ENGINE_PILE));
+            fnd = OPENSSL_malloc(sizeof(*fnd));
             if (!fnd)
                 goto end;
             fnd->uptodate = 1;
diff --git a/crypto/err/err.c b/crypto/err/err.c
index e1091e3..78e8817 100644
--- a/crypto/err/err.c
+++ b/crypto/err/err.c
@@ -455,8 +455,8 @@ static void build_SYS_str_reasons(void)
             char (*dest)[LEN_SYS_STR_REASON] = &(strerror_tab[i - 1]);
             char *src = strerror(i);
             if (src != NULL) {
-                strncpy(*dest, src, sizeof *dest);
-                (*dest)[sizeof *dest - 1] = '\0';
+                strncpy(*dest, src, sizeof(*dest));
+                (*dest)[sizeof(*dest) - 1] = '\0';
                 str->string = *dest;
             }
         }
@@ -882,7 +882,7 @@ ERR_STATE *ERR_get_state(void)
 
     /* ret == the error state, if NULL, make a new one */
     if (ret == NULL) {
-        ret = OPENSSL_malloc(sizeof(ERR_STATE));
+        ret = OPENSSL_malloc(sizeof(*ret));
         if (ret == NULL)
             return (&fallback);
         CRYPTO_THREADID_cpy(&ret->tid, &tid);
diff --git a/crypto/evp/bio_b64.c b/crypto/evp/bio_b64.c
index fe772fc..6dc3bb1 100644
--- a/crypto/evp/bio_b64.c
+++ b/crypto/evp/bio_b64.c
@@ -115,7 +115,7 @@ static int b64_new(BIO *bi)
 {
     BIO_B64_CTX *ctx;
 
-    ctx = OPENSSL_malloc(sizeof(BIO_B64_CTX));
+    ctx = OPENSSL_malloc(sizeof(*ctx));
     if (ctx == NULL)
         return (0);
 
diff --git a/crypto/evp/bio_enc.c b/crypto/evp/bio_enc.c
index 0afd8cc..86a2dc5 100644
--- a/crypto/evp/bio_enc.c
+++ b/crypto/evp/bio_enc.c
@@ -112,7 +112,7 @@ static int enc_new(BIO *bi)
 {
     BIO_ENC_CTX *ctx;
 
-    ctx = OPENSSL_malloc(sizeof(BIO_ENC_CTX));
+    ctx = OPENSSL_malloc(sizeof(*ctx));
     if (ctx == NULL)
         return (0);
     EVP_CIPHER_CTX_init(&ctx->cipher);
diff --git a/crypto/evp/bio_ok.c b/crypto/evp/bio_ok.c
index eced061..9a65a9d 100644
--- a/crypto/evp/bio_ok.c
+++ b/crypto/evp/bio_ok.c
@@ -176,7 +176,7 @@ static int ok_new(BIO *bi)
 {
     BIO_OK_CTX *ctx;
 
-    ctx = OPENSSL_malloc(sizeof(BIO_OK_CTX));
+    ctx = OPENSSL_malloc(sizeof(*ctx));
     if (ctx == NULL)
         return (0);
 
diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c
index 043830d..04ab3a0 100644
--- a/crypto/evp/digest.c
+++ b/crypto/evp/digest.c
@@ -119,12 +119,12 @@
 
 void EVP_MD_CTX_init(EVP_MD_CTX *ctx)
 {
-    memset(ctx, '\0', sizeof *ctx);
+    memset(ctx, '\0', sizeof(*ctx));
 }
 
 EVP_MD_CTX *EVP_MD_CTX_create(void)
 {
-    EVP_MD_CTX *ctx = OPENSSL_malloc(sizeof *ctx);
+    EVP_MD_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));
 
     if (ctx)
         EVP_MD_CTX_init(ctx);
@@ -281,7 +281,7 @@ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)
     } else
         tmp_buf = NULL;
     EVP_MD_CTX_cleanup(out);
-    memcpy(out, in, sizeof *out);
+    memcpy(out, in, sizeof(*out));
 
     if (in->md_data && out->digest->ctx_size) {
         if (tmp_buf)
@@ -360,7 +360,7 @@ int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)
          */
         ENGINE_finish(ctx->engine);
 #endif
-    memset(ctx, '\0', sizeof *ctx);
+    memset(ctx, '\0', sizeof(*ctx));
 
     return 1;
 }
diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c
index c2387b9..4dfc159 100644
--- a/crypto/evp/evp_enc.c
+++ b/crypto/evp/evp_enc.c
@@ -76,7 +76,7 @@ void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx)
 
 EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void)
 {
-    EVP_CIPHER_CTX *ctx = OPENSSL_malloc(sizeof *ctx);
+    EVP_CIPHER_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));
     if (ctx)
         EVP_CIPHER_CTX_init(ctx);
     return ctx;
@@ -619,7 +619,7 @@ int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in)
 #endif
 
     EVP_CIPHER_CTX_cleanup(out);
-    memcpy(out, in, sizeof *out);
+    memcpy(out, in, sizeof(*out));
 
     if (in->cipher_data && in->cipher->ctx_size) {
         out->cipher_data = OPENSSL_malloc(in->cipher->ctx_size);
diff --git a/crypto/evp/evp_pbe.c b/crypto/evp/evp_pbe.c
index 6128a73..0f32507 100644
--- a/crypto/evp/evp_pbe.c
+++ b/crypto/evp/evp_pbe.c
@@ -226,9 +226,10 @@ int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid,
                          int md_nid, EVP_PBE_KEYGEN *keygen)
 {
     EVP_PBE_CTL *pbe_tmp;
+
     if (!pbe_algs)
         pbe_algs = sk_EVP_PBE_CTL_new(pbe_cmp);
-    if (!(pbe_tmp = OPENSSL_malloc(sizeof(EVP_PBE_CTL)))) {
+    if (!(pbe_tmp = OPENSSL_malloc(sizeof(*pbe_tmp)))) {
         EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE, ERR_R_MALLOC_FAILURE);
         return 0;
     }
diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c
index c163e47..42ae5ae 100644
--- a/crypto/evp/p_lib.c
+++ b/crypto/evp/p_lib.c
@@ -185,7 +185,7 @@ EVP_PKEY *EVP_PKEY_new(void)
 {
     EVP_PKEY *ret;
 
-    ret = OPENSSL_malloc(sizeof(EVP_PKEY));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (ret == NULL) {
         EVPerr(EVP_F_EVP_PKEY_NEW, ERR_R_MALLOC_FAILURE);
         return (NULL);
diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c
index b20a902..397d342 100644
--- a/crypto/evp/pmeth_lib.c
+++ b/crypto/evp/pmeth_lib.c
@@ -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,7 +197,8 @@ 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;
 
@@ -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;
 
diff --git a/crypto/ex_data.c b/crypto/ex_data.c
index 96ecd94..20a2dd7 100644
--- a/crypto/ex_data.c
+++ b/crypto/ex_data.c
@@ -318,7 +318,7 @@ static EX_CLASS_ITEM *def_get_class(int class_index)
     CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
     p = lh_EX_CLASS_ITEM_retrieve(ex_data, &d);
     if (!p) {
-        gen = OPENSSL_malloc(sizeof(EX_CLASS_ITEM));
+        gen = OPENSSL_malloc(sizeof(*gen));
         if (gen) {
             gen->class_index = class_index;
             gen->meth_num = 0;
@@ -350,7 +350,7 @@ static int def_add_index(EX_CLASS_ITEM *item, long argl, void *argp,
                          CRYPTO_EX_free *free_func)
 {
     int toret = -1;
-    CRYPTO_EX_DATA_FUNCS *a = OPENSSL_malloc(sizeof(CRYPTO_EX_DATA_FUNCS));
+    CRYPTO_EX_DATA_FUNCS *a = OPENSSL_malloc(sizeof(*a));
     if (!a) {
         CRYPTOerr(CRYPTO_F_DEF_ADD_INDEX, ERR_R_MALLOC_FAILURE);
         return -1;
diff --git a/crypto/hmac/hm_pmeth.c b/crypto/hmac/hm_pmeth.c
index f53f78c..845a72b 100644
--- a/crypto/hmac/hm_pmeth.c
+++ b/crypto/hmac/hm_pmeth.c
@@ -75,7 +75,7 @@ typedef struct {
 static int pkey_hmac_init(EVP_PKEY_CTX *ctx)
 {
     HMAC_PKEY_CTX *hctx;
-    hctx = OPENSSL_malloc(sizeof(HMAC_PKEY_CTX));
+    hctx = OPENSSL_malloc(sizeof(*hctx));
     if (!hctx)
         return 0;
     hctx->md = NULL;
diff --git a/crypto/hmac/hmac.c b/crypto/hmac/hmac.c
index ccfd16e..6362aa8 100644
--- a/crypto/hmac/hmac.c
+++ b/crypto/hmac/hmac.c
@@ -197,7 +197,7 @@ void HMAC_CTX_cleanup(HMAC_CTX *ctx)
     EVP_MD_CTX_cleanup(&ctx->i_ctx);
     EVP_MD_CTX_cleanup(&ctx->o_ctx);
     EVP_MD_CTX_cleanup(&ctx->md_ctx);
-    memset(ctx, 0, sizeof *ctx);
+    memset(ctx, 0, sizeof(*ctx));
 }
 
 unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
diff --git a/crypto/jpake/jpake.c b/crypto/jpake/jpake.c
index b097c7f..b494ac0 100644
--- a/crypto/jpake/jpake.c
+++ b/crypto/jpake/jpake.c
@@ -107,14 +107,14 @@ static void JPAKE_CTX_release(JPAKE_CTX *ctx)
     OPENSSL_free(ctx->p.peer_name);
     OPENSSL_free(ctx->p.name);
 
-    memset(ctx, '\0', sizeof *ctx);
+    memset(ctx, '\0', sizeof(*ctx));
 }
 
 JPAKE_CTX *JPAKE_CTX_new(const char *name, const char *peer_name,
                          const BIGNUM *p, const BIGNUM *g, const BIGNUM *q,
                          const BIGNUM *secret)
 {
-    JPAKE_CTX *ctx = OPENSSL_malloc(sizeof *ctx);
+    JPAKE_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));
     if (ctx == NULL)
         return NULL;
 
diff --git a/crypto/lhash/lhash.c b/crypto/lhash/lhash.c
index ac3b5f6..083310e 100644
--- a/crypto/lhash/lhash.c
+++ b/crypto/lhash/lhash.c
@@ -117,9 +117,9 @@ _LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c)
     _LHASH *ret;
     int i;
 
-    if ((ret = OPENSSL_malloc(sizeof(_LHASH))) == NULL)
+    if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
         goto err0;
-    if ((ret->b = OPENSSL_malloc(sizeof(LHASH_NODE *) * MIN_NODES)) == NULL)
+    if ((ret->b = OPENSSL_malloc(sizeof(*ret->b) * MIN_NODES)) == NULL)
         goto err1;
     for (i = 0; i < MIN_NODES; i++)
         ret->b[i] = NULL;
@@ -188,7 +188,7 @@ void *lh_insert(_LHASH *lh, void *data)
     rn = getrn(lh, data, &hash);
 
     if (*rn == NULL) {
-        if ((nn = OPENSSL_malloc(sizeof(LHASH_NODE))) == NULL) {
+        if ((nn = OPENSSL_malloc(sizeof(*nn))) == NULL) {
             lh->error++;
             return (NULL);
         }
diff --git a/crypto/lock.c b/crypto/lock.c
index cc5f47a..cad9876 100644
--- a/crypto/lock.c
+++ b/crypto/lock.c
@@ -251,7 +251,7 @@ int CRYPTO_get_new_dynlockid(void)
     }
     CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
 
-    pointer = OPENSSL_malloc(sizeof(CRYPTO_dynlock));
+    pointer = OPENSSL_malloc(sizeof(*pointer));
     if (pointer == NULL) {
         CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, ERR_R_MALLOC_FAILURE);
         return (0);
diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c
index dee1fb9..98c17dd 100644
--- a/crypto/mem_dbg.c
+++ b/crypto/mem_dbg.c
@@ -394,7 +394,7 @@ int CRYPTO_push_info_(const char *info, const char *file, int line)
     if (is_MemCheck_on()) {
         MemCheck_off();         /* obtain MALLOC2 lock */
 
-        if ((ami = OPENSSL_malloc(sizeof(APP_INFO))) == NULL) {
+        if ((ami = OPENSSL_malloc(sizeof(*ami))) == NULL) {
             ret = 0;
             goto err;
         }
@@ -478,7 +478,7 @@ void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
 
         if (is_MemCheck_on()) {
             MemCheck_off();     /* make sure we hold MALLOC2 lock */
-            if ((m = OPENSSL_malloc(sizeof(MEM))) == NULL) {
+            if ((m = OPENSSL_malloc(sizeof(*m))) == NULL) {
                 OPENSSL_free(addr);
                 MemCheck_on();  /* release MALLOC2 lock if num_disabled drops
                                  * to 0 */
diff --git a/crypto/modes/gcm128.c b/crypto/modes/gcm128.c
index 780b326..b39cd06 100644
--- a/crypto/modes/gcm128.c
+++ b/crypto/modes/gcm128.c
@@ -1701,7 +1701,7 @@ GCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block)
 {
     GCM128_CONTEXT *ret;
 
-    if ((ret = OPENSSL_malloc(sizeof(GCM128_CONTEXT))))
+    if ((ret = OPENSSL_malloc(sizeof(*ret))))
         CRYPTO_gcm128_init(ret, key, block);
 
     return ret;
diff --git a/crypto/modes/ocb128.c b/crypto/modes/ocb128.c
index efa403b..79b7862 100644
--- a/crypto/modes/ocb128.c
+++ b/crypto/modes/ocb128.c
@@ -210,7 +210,7 @@ OCB128_CONTEXT *CRYPTO_ocb128_new(void *keyenc, void *keydec,
     OCB128_CONTEXT *octx;
     int ret;
 
-    if ((octx = OPENSSL_malloc(sizeof(OCB128_CONTEXT)))) {
+    if ((octx = OPENSSL_malloc(sizeof(*octx)))) {
         ret = CRYPTO_ocb128_init(octx, keyenc, keydec, encrypt, decrypt);
         if (ret)
             return octx;
diff --git a/crypto/objects/Makefile b/crypto/objects/Makefile
index ad2db1e..6e9fa2e 100644
--- a/crypto/objects/Makefile
+++ b/crypto/objects/Makefile
@@ -106,10 +106,10 @@ obj_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
 obj_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
 obj_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
 obj_lib.o: ../cryptlib.h ../include/internal/asn1_int.h obj_lib.c
-obj_xref.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
-obj_xref.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
-obj_xref.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
-obj_xref.o: ../../include/openssl/opensslconf.h
+obj_xref.o: ../../e_os.h ../../include/openssl/asn1.h
+obj_xref.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
+obj_xref.o: ../../include/openssl/e_os2.h ../../include/openssl/obj_mac.h
+obj_xref.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
 obj_xref.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
 obj_xref.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
 obj_xref.o: ../../include/openssl/symhacks.h obj_xref.c obj_xref.h
diff --git a/crypto/objects/o_names.c b/crypto/objects/o_names.c
index 1fa6426..d861b6d 100644
--- a/crypto/objects/o_names.c
+++ b/crypto/objects/o_names.c
@@ -83,7 +83,7 @@ int OBJ_NAME_new_index(unsigned long (*hash_func) (const char *),
     names_type_num++;
     for (i = sk_NAME_FUNCS_num(name_funcs_stack); i < names_type_num; i++) {
         MemCheck_off();
-        name_funcs = OPENSSL_malloc(sizeof(NAME_FUNCS));
+        name_funcs = OPENSSL_malloc(sizeof(*name_funcs));
         MemCheck_on();
         if (!name_funcs) {
             OBJerr(OBJ_F_OBJ_NAME_NEW_INDEX, ERR_R_MALLOC_FAILURE);
@@ -187,7 +187,7 @@ int OBJ_NAME_add(const char *name, int type, const char *data)
     alias = type & OBJ_NAME_ALIAS;
     type &= ~OBJ_NAME_ALIAS;
 
-    onp = OPENSSL_malloc(sizeof(OBJ_NAME));
+    onp = OPENSSL_malloc(sizeof(*onp));
     if (onp == NULL) {
         /* ERROR */
         return (0);
@@ -310,13 +310,13 @@ void OBJ_NAME_do_all_sorted(int type,
 
     d.type = type;
     d.names =
-        OPENSSL_malloc(lh_OBJ_NAME_num_items(names_lh) * sizeof *d.names);
+        OPENSSL_malloc(sizeof(*d.names) * lh_OBJ_NAME_num_items(names_lh));
     /* Really should return an error if !d.names...but its a void function! */
     if (d.names) {
         d.n = 0;
         OBJ_NAME_do_all(type, do_all_sorted_fn, &d);
 
-        qsort((void *)d.names, d.n, sizeof *d.names, do_all_sorted_cmp);
+        qsort((void *)d.names, d.n, sizeof(*d.names), do_all_sorted_cmp);
 
         for (n = 0; n < d.n; ++n)
             fn(d.names[n], arg);
diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c
index bca3ded..82af4a4 100644
--- a/crypto/objects/obj_dat.c
+++ b/crypto/objects/obj_dat.c
@@ -255,19 +255,16 @@ int OBJ_add_object(const ASN1_OBJECT *obj)
             return (0);
     if ((o = OBJ_dup(obj)) == NULL)
         goto err;
-    if (!(ao[ADDED_NID] = OPENSSL_malloc(sizeof(ADDED_OBJ))))
+    if (!(ao[ADDED_NID] = OPENSSL_malloc(sizeof(*ao))))
         goto err2;
     if ((o->length != 0) && (obj->data != NULL))
-        if (!
-            (ao[ADDED_DATA] = OPENSSL_malloc(sizeof(ADDED_OBJ))))
+        if (!(ao[ADDED_DATA] = OPENSSL_malloc(sizeof(*ao))))
             goto err2;
     if (o->sn != NULL)
-        if (!
-            (ao[ADDED_SNAME] = OPENSSL_malloc(sizeof(ADDED_OBJ))))
+        if (!(ao[ADDED_SNAME] = OPENSSL_malloc(sizeof(*ao))))
             goto err2;
     if (o->ln != NULL)
-        if (!
-            (ao[ADDED_LNAME] = OPENSSL_malloc(sizeof(ADDED_OBJ))))
+        if (!(ao[ADDED_LNAME] = OPENSSL_malloc(sizeof(*ao))))
             goto err2;
 
     for (i = ADDED_DATA; i <= ADDED_NID; i++) {
diff --git a/crypto/objects/obj_xref.c b/crypto/objects/obj_xref.c
index 10ce639..44471a3 100644
--- a/crypto/objects/obj_xref.c
+++ b/crypto/objects/obj_xref.c
@@ -154,7 +154,7 @@ int OBJ_add_sigid(int signid, int dig_id, int pkey_id)
         sigx_app = sk_nid_triple_new(sigx_cmp);
     if (!sigx_app)
         return 0;
-    ntr = OPENSSL_malloc(sizeof(int) * 3);
+    ntr = OPENSSL_malloc(sizeof(*ntr));
     if (!ntr)
         return 0;
     ntr->sign_id = signid;
diff --git a/crypto/ocsp/ocsp_ht.c b/crypto/ocsp/ocsp_ht.c
index aa10c03..582ef9c 100644
--- a/crypto/ocsp/ocsp_ht.c
+++ b/crypto/ocsp/ocsp_ht.c
@@ -113,8 +113,8 @@ static int parse_http_line1(char *line);
 
 OCSP_REQ_CTX *OCSP_REQ_CTX_new(BIO *io, int maxline)
 {
-    OCSP_REQ_CTX *rctx;
-    rctx = OPENSSL_malloc(sizeof(OCSP_REQ_CTX));
+    OCSP_REQ_CTX *rctx = OPENSSL_malloc(sizeof(*rctx));
+
     if (!rctx)
         return NULL;
     rctx->state = OHS_ERROR;
diff --git a/crypto/pqueue/pqueue.c b/crypto/pqueue/pqueue.c
index 725fe38..d66efe1 100644
--- a/crypto/pqueue/pqueue.c
+++ b/crypto/pqueue/pqueue.c
@@ -68,7 +68,7 @@ typedef struct _pqueue {
 
 pitem *pitem_new(unsigned char *prio64be, void *data)
 {
-    pitem *item = OPENSSL_malloc(sizeof(pitem));
+    pitem *item = OPENSSL_malloc(sizeof(*item));
     if (item == NULL)
         return NULL;
 
@@ -87,7 +87,7 @@ void pitem_free(pitem *item)
 
 pqueue_s *pqueue_new()
 {
-    pqueue_s *pq = OPENSSL_malloc(sizeof(pqueue_s));
+    pqueue_s *pq = OPENSSL_malloc(sizeof(*pq));
     if (pq == NULL)
         return NULL;
 
diff --git a/crypto/rsa/rsa_lib.c b/crypto/rsa/rsa_lib.c
index d8a9132..7d8fd39 100644
--- a/crypto/rsa/rsa_lib.c
+++ b/crypto/rsa/rsa_lib.c
@@ -127,7 +127,7 @@ RSA *RSA_new_method(ENGINE *engine)
 {
     RSA *ret;
 
-    ret = OPENSSL_malloc(sizeof(RSA));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (ret == NULL) {
         RSAerr(RSA_F_RSA_NEW_METHOD, ERR_R_MALLOC_FAILURE);
         return NULL;
diff --git a/crypto/rsa/rsa_pmeth.c b/crypto/rsa/rsa_pmeth.c
index 94dc408..e407671 100644
--- a/crypto/rsa/rsa_pmeth.c
+++ b/crypto/rsa/rsa_pmeth.c
@@ -97,7 +97,7 @@ typedef struct {
 static int pkey_rsa_init(EVP_PKEY_CTX *ctx)
 {
     RSA_PKEY_CTX *rctx;
-    rctx = OPENSSL_malloc(sizeof(RSA_PKEY_CTX));
+    rctx = OPENSSL_malloc(sizeof(*rctx));
     if (!rctx)
         return 0;
     rctx->nbits = 1024;
diff --git a/crypto/srp/srp_vfy.c b/crypto/srp/srp_vfy.c
index cd07f70..075c9ed 100644
--- a/crypto/srp/srp_vfy.c
+++ b/crypto/srp/srp_vfy.c
@@ -198,7 +198,7 @@ static void SRP_user_pwd_free(SRP_user_pwd *user_pwd)
 
 static SRP_user_pwd *SRP_user_pwd_new(void)
 {
-    SRP_user_pwd *ret = OPENSSL_malloc(sizeof(SRP_user_pwd));
+    SRP_user_pwd *ret = OPENSSL_malloc(sizeof(*ret));
     if (ret == NULL)
         return NULL;
     ret->N = NULL;
@@ -249,7 +249,7 @@ static int SRP_user_pwd_set_sv_BN(SRP_user_pwd *vinfo, BIGNUM *s, BIGNUM *v)
 
 SRP_VBASE *SRP_VBASE_new(char *seed_key)
 {
-    SRP_VBASE *vb = OPENSSL_malloc(sizeof(SRP_VBASE));
+    SRP_VBASE *vb = OPENSSL_malloc(sizeof(*vb));
 
     if (vb == NULL)
         return NULL;
@@ -284,7 +284,7 @@ static SRP_gN_cache *SRP_gN_new_init(const char *ch)
 {
     unsigned char tmp[MAX_LEN];
     int len;
-    SRP_gN_cache *newgN = OPENSSL_malloc(sizeof(SRP_gN_cache));
+    SRP_gN_cache *newgN = OPENSSL_malloc(sizeof(*newgN));
 
     if (newgN == NULL)
         return NULL;
@@ -391,7 +391,7 @@ int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file)
              * we add this couple in the internal Stack
              */
 
-            if ((gN = OPENSSL_malloc(sizeof(SRP_gN))) == NULL)
+            if ((gN = OPENSSL_malloc(sizeof(*gN))) == NULL)
                 goto err;
 
             if (!(gN->id = BUF_strdup(pp[DB_srpid]))
diff --git a/crypto/stack/stack.c b/crypto/stack/stack.c
index 7922188..efabe16 100644
--- a/crypto/stack/stack.c
+++ b/crypto/stack/stack.c
@@ -122,7 +122,7 @@ _STACK *sk_deep_copy(_STACK *sk, void *(*copy_func) (void *),
     ret->sorted = sk->sorted;
     ret->num = sk->num;
     ret->num_alloc = sk->num > MIN_NODES ? sk->num : MIN_NODES;
-    ret->data = OPENSSL_malloc(sizeof(char *) * ret->num_alloc);
+    ret->data = OPENSSL_malloc(sizeof(*ret->data) * ret->num_alloc);
     if (ret->data == NULL) {
         OPENSSL_free(ret);
         return NULL;
@@ -156,7 +156,7 @@ _STACK *sk_new(int (*c) (const void *, const void *))
 
     if ((ret = OPENSSL_malloc(sizeof(_STACK))) == NULL)
         goto err;
-    if ((ret->data = OPENSSL_malloc(sizeof(char *) * MIN_NODES)) == NULL)
+    if ((ret->data = OPENSSL_malloc(sizeof(*ret->data) * MIN_NODES)) == NULL)
         goto err;
     for (i = 0; i < MIN_NODES; i++)
         ret->data[i] = NULL;
diff --git a/crypto/store/str_lib.c b/crypto/store/str_lib.c
index 1a4f237..fef7111 100644
--- a/crypto/store/str_lib.c
+++ b/crypto/store/str_lib.c
@@ -109,7 +109,7 @@ STORE *STORE_new_method(const STORE_METHOD *method)
         return NULL;
     }
 
-    ret = OPENSSL_malloc(sizeof(STORE));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (ret == NULL) {
         STOREerr(STORE_F_STORE_NEW_METHOD, ERR_R_MALLOC_FAILURE);
         return NULL;
@@ -1156,9 +1156,9 @@ int STORE_delete_arbitrary(STORE *s, OPENSSL_ITEM attributes[],
 
 STORE_OBJECT *STORE_OBJECT_new(void)
 {
-    STORE_OBJECT *object = OPENSSL_malloc(sizeof(STORE_OBJECT));
+    STORE_OBJECT *object = OPENSSL_malloc(sizeof(*object));
     if (object)
-        memset(object, 0, sizeof(STORE_OBJECT));
+        memset(object, 0, sizeof(*object));
     return object;
 }
 
@@ -1206,7 +1206,9 @@ struct STORE_attr_info_st {
 
 STORE_ATTR_INFO *STORE_ATTR_INFO_new(void)
 {
-    return OPENSSL_malloc(sizeof(STORE_ATTR_INFO));
+    STORE_ATTR_INFO *p = OPENSSL_malloc(sizeof(*p));
+
+    return p;
 }
 
 static void STORE_ATTR_INFO_attr_free(STORE_ATTR_INFO *attrs,
@@ -1450,8 +1452,7 @@ struct attr_list_ctx_st {
 void *STORE_parse_attrs_start(OPENSSL_ITEM *attributes)
 {
     if (attributes) {
-        struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)
-            OPENSSL_malloc(sizeof(struct attr_list_ctx_st));
+        struct attr_list_ctx_st *context = OPENSSL_malloc(sizeof(*context));
         if (context)
             context->attributes = attributes;
         else
diff --git a/crypto/store/str_mem.c b/crypto/store/str_mem.c
index f1cca6a..632ada8 100644
--- a/crypto/store/str_mem.c
+++ b/crypto/store/str_mem.c
@@ -244,7 +244,7 @@ static void *mem_list_start(STORE *s, STORE_OBJECT_TYPES type,
                             OPENSSL_ITEM attributes[],
                             OPENSSL_ITEM parameters[])
 {
-    struct mem_ctx_st *context = OPENSSL_malloc(sizeof(struct mem_ctx_st));
+    struct mem_ctx_st *context = OPENSSL_malloc(sizeof(*context));
     void *attribute_context = NULL;
     STORE_ATTR_INFO *attrs = NULL;
 
diff --git a/crypto/store/str_meth.c b/crypto/store/str_meth.c
index 781b160..7487819 100644
--- a/crypto/store/str_meth.c
+++ b/crypto/store/str_meth.c
@@ -63,7 +63,7 @@
 
 STORE_METHOD *STORE_create_method(char *name)
 {
-    STORE_METHOD *store_method = OPENSSL_malloc(sizeof(STORE_METHOD));
+    STORE_METHOD *store_method = OPENSSL_malloc(sizeof(*store_method));
 
     if (store_method) {
         memset(store_method, 0, sizeof(*store_method));
diff --git a/crypto/ts/ts_rsp_sign.c b/crypto/ts/ts_rsp_sign.c
index 58068cf..2d1e438 100644
--- a/crypto/ts/ts_rsp_sign.c
+++ b/crypto/ts/ts_rsp_sign.c
@@ -169,7 +169,7 @@ TS_RESP_CTX *TS_RESP_CTX_new()
 {
     TS_RESP_CTX *ctx;
 
-    if (!(ctx = OPENSSL_malloc(sizeof(TS_RESP_CTX)))) {
+    if (!(ctx = OPENSSL_malloc(sizeof(*ctx)))) {
         TSerr(TS_F_TS_RESP_CTX_NEW, ERR_R_MALLOC_FAILURE);
         return NULL;
     }
diff --git a/crypto/ts/ts_verify_ctx.c b/crypto/ts/ts_verify_ctx.c
index f328c33..651b1d1 100644
--- a/crypto/ts/ts_verify_ctx.c
+++ b/crypto/ts/ts_verify_ctx.c
@@ -63,7 +63,7 @@
 
 TS_VERIFY_CTX *TS_VERIFY_CTX_new(void)
 {
-    TS_VERIFY_CTX *ctx = OPENSSL_malloc(sizeof(TS_VERIFY_CTX));
+    TS_VERIFY_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));
 
     if (ctx)
         memset(ctx, 0, sizeof(TS_VERIFY_CTX));
diff --git a/crypto/txt_db/txt_db.c b/crypto/txt_db/txt_db.c
index 49d8ccc..54c85d2 100644
--- a/crypto/txt_db/txt_db.c
+++ b/crypto/txt_db/txt_db.c
@@ -85,7 +85,7 @@ TXT_DB *TXT_DB_read(BIO *in, int num)
     if (!BUF_MEM_grow(buf, size))
         goto err;
 
-    if ((ret = OPENSSL_malloc(sizeof(TXT_DB))) == NULL)
+    if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
         goto err;
     ret->num_fields = num;
     ret->index = NULL;
diff --git a/crypto/ui/ui_lib.c b/crypto/ui/ui_lib.c
index 26afbd2..e090b88 100644
--- a/crypto/ui/ui_lib.c
+++ b/crypto/ui/ui_lib.c
@@ -74,7 +74,7 @@ UI *UI_new(void)
 
 UI *UI_new_method(const UI_METHOD *method)
 {
-    UI *ret = OPENSSL_malloc(sizeof(UI));
+    UI *ret = OPENSSL_malloc(sizeof(*ret));
 
     if (ret == NULL) {
         UIerr(UI_F_UI_NEW_METHOD, ERR_R_MALLOC_FAILURE);
@@ -141,7 +141,7 @@ static UI_STRING *general_allocate_prompt(UI *ui, const char *prompt,
     } else if ((type == UIT_PROMPT || type == UIT_VERIFY
                 || type == UIT_BOOLEAN) && result_buf == NULL) {
         UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, UI_R_NO_RESULT_BUFFER);
-    } else if ((ret = OPENSSL_malloc(sizeof(UI_STRING)))) {
+    } else if ((ret = OPENSSL_malloc(sizeof(*ret)))) {
         ret->out_string = prompt;
         ret->flags = prompt_freeable ? OUT_STRING_FREEABLE : 0;
         ret->input_flags = input_flags;
@@ -582,7 +582,7 @@ const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth)
 
 UI_METHOD *UI_create_method(char *name)
 {
-    UI_METHOD *ui_method = OPENSSL_malloc(sizeof(UI_METHOD));
+    UI_METHOD *ui_method = OPENSSL_malloc(sizeof(*ui_method));
 
     if (ui_method) {
         memset(ui_method, 0, sizeof(*ui_method));
diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c
index 304cf4a..1be5309 100644
--- a/crypto/x509/by_dir.c
+++ b/crypto/x509/by_dir.c
@@ -148,7 +148,7 @@ static int new_dir(X509_LOOKUP *lu)
 {
     BY_DIR *a;
 
-    if ((a = OPENSSL_malloc(sizeof(BY_DIR))) == NULL)
+    if ((a = OPENSSL_malloc(sizeof(*a))) == NULL)
         return (0);
     if ((a->buffer = BUF_MEM_new()) == NULL) {
         OPENSSL_free(a);
@@ -226,7 +226,7 @@ static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)
                     return 0;
                 }
             }
-            ent = OPENSSL_malloc(sizeof(BY_DIR_ENTRY));
+            ent = OPENSSL_malloc(sizeof(*ent));
             if (!ent)
                 return 0;
             ent->dir_type = type;
@@ -396,7 +396,7 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
                     hent = sk_BY_DIR_HASH_value(ent->hashes, idx);
             }
             if (!hent) {
-                hent = OPENSSL_malloc(sizeof(BY_DIR_HASH));
+                hent = OPENSSL_malloc(sizeof(*hent));
                 if (hent == NULL) {
                     CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
                     X509err(X509_F_GET_CERT_BY_SUBJECT, ERR_R_MALLOC_FAILURE);
diff --git a/crypto/x509/x509_lu.c b/crypto/x509/x509_lu.c
index 7fbc8e3..5017f02 100644
--- a/crypto/x509/x509_lu.c
+++ b/crypto/x509/x509_lu.c
@@ -67,7 +67,7 @@ X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method)
 {
     X509_LOOKUP *ret;
 
-    ret = OPENSSL_malloc(sizeof(X509_LOOKUP));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (ret == NULL)
         return NULL;
 
@@ -184,7 +184,7 @@ X509_STORE *X509_STORE_new(void)
 {
     X509_STORE *ret;
 
-    if ((ret = OPENSSL_malloc(sizeof(X509_STORE))) == NULL)
+    if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
         return NULL;
     ret->objs = sk_X509_OBJECT_new(x509_object_cmp);
     ret->cache = 1;
@@ -342,7 +342,7 @@ int X509_STORE_add_cert(X509_STORE *ctx, X509 *x)
 
     if (x == NULL)
         return 0;
-    obj = OPENSSL_malloc(sizeof(X509_OBJECT));
+    obj = OPENSSL_malloc(sizeof(*obj));
     if (obj == NULL) {
         X509err(X509_F_X509_STORE_ADD_CERT, ERR_R_MALLOC_FAILURE);
         return 0;
@@ -375,7 +375,7 @@ int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x)
 
     if (x == NULL)
         return 0;
-    obj = OPENSSL_malloc(sizeof(X509_OBJECT));
+    obj = OPENSSL_malloc(sizeof(*obj));
     if (obj == NULL) {
         X509err(X509_F_X509_STORE_ADD_CRL, ERR_R_MALLOC_FAILURE);
         return 0;
diff --git a/crypto/x509/x509_trs.c b/crypto/x509/x509_trs.c
index 6632f9b..4207f42 100644
--- a/crypto/x509/x509_trs.c
+++ b/crypto/x509/x509_trs.c
@@ -188,7 +188,7 @@ int X509_TRUST_add(int id, int flags, int (*ck) (X509_TRUST *, X509 *, int),
     idx = X509_TRUST_get_by_id(id);
     /* Need a new entry */
     if (idx == -1) {
-        if (!(trtmp = OPENSSL_malloc(sizeof(X509_TRUST)))) {
+        if (!(trtmp = OPENSSL_malloc(sizeof(*trtmp)))) {
             X509err(X509_F_X509_TRUST_ADD, ERR_R_MALLOC_FAILURE);
             return 0;
         }
diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c
index 3f4fb81..8c0680b 100644
--- a/crypto/x509/x509_vfy.c
+++ b/crypto/x509/x509_vfy.c
@@ -2211,9 +2211,8 @@ int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
 
 X509_STORE_CTX *X509_STORE_CTX_new(void)
 {
-    X509_STORE_CTX *ctx;
+    X509_STORE_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));
 
-    ctx = OPENSSL_malloc(sizeof(X509_STORE_CTX));
     if (!ctx) {
         X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE);
         return NULL;
diff --git a/crypto/x509/x509_vpm.c b/crypto/x509/x509_vpm.c
index 1d88f56..4b6ec63 100644
--- a/crypto/x509/x509_vpm.c
+++ b/crypto/x509/x509_vpm.c
@@ -161,16 +161,16 @@ X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void)
     X509_VERIFY_PARAM *param;
     X509_VERIFY_PARAM_ID *paramid;
 
-    param = OPENSSL_malloc(sizeof *param);
+    param = OPENSSL_malloc(sizeof(*param));
     if (!param)
         return NULL;
-    paramid = OPENSSL_malloc(sizeof *paramid);
+    paramid = OPENSSL_malloc(sizeof(*paramid));
     if (!paramid) {
         OPENSSL_free(param);
         return NULL;
     }
-    memset(param, 0, sizeof *param);
-    memset(paramid, 0, sizeof *paramid);
+    memset(param, 0, sizeof(*param));
+    memset(paramid, 0, sizeof(*paramid));
     param->id = paramid;
     x509_verify_param_zero(param);
     return param;
diff --git a/crypto/x509/x_name.c b/crypto/x509/x_name.c
index cab7171..e61dfb2 100644
--- a/crypto/x509/x_name.c
+++ b/crypto/x509/x_name.c
@@ -133,8 +133,8 @@ IMPLEMENT_ASN1_DUP_FUNCTION(X509_NAME)
 
 static int x509_name_ex_new(ASN1_VALUE **val, const ASN1_ITEM *it)
 {
-    X509_NAME *ret = NULL;
-    ret = OPENSSL_malloc(sizeof(X509_NAME));
+    X509_NAME *ret = OPENSSL_malloc(sizeof(*ret));
+
     if (!ret)
         goto memerr;
     if ((ret->entries = sk_X509_NAME_ENTRY_new_null()) == NULL)
diff --git a/crypto/x509v3/pcy_cache.c b/crypto/x509v3/pcy_cache.c
index 1f94260..8e78011 100644
--- a/crypto/x509v3/pcy_cache.c
+++ b/crypto/x509v3/pcy_cache.c
@@ -127,7 +127,7 @@ static int policy_cache_new(X509 *x)
     CERTIFICATEPOLICIES *ext_cpols = NULL;
     POLICY_MAPPINGS *ext_pmaps = NULL;
     int i;
-    cache = OPENSSL_malloc(sizeof(X509_POLICY_CACHE));
+    cache = OPENSSL_malloc(sizeof(*cache));
     if (!cache)
         return 0;
     cache->anyPolicy = NULL;
diff --git a/crypto/x509v3/pcy_data.c b/crypto/x509v3/pcy_data.c
index 37c867e..ef6edb1 100644
--- a/crypto/x509v3/pcy_data.c
+++ b/crypto/x509v3/pcy_data.c
@@ -98,7 +98,7 @@ X509_POLICY_DATA *policy_data_new(POLICYINFO *policy,
             return NULL;
     } else
         id = NULL;
-    ret = OPENSSL_malloc(sizeof(X509_POLICY_DATA));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (!ret)
         return NULL;
     ret->expected_policy_set = sk_ASN1_OBJECT_new_null();
diff --git a/crypto/x509v3/pcy_node.c b/crypto/x509v3/pcy_node.c
index d6c9176..855fe3e 100644
--- a/crypto/x509v3/pcy_node.c
+++ b/crypto/x509v3/pcy_node.c
@@ -114,7 +114,7 @@ X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
                                  X509_POLICY_TREE *tree)
 {
     X509_POLICY_NODE *node;
-    node = OPENSSL_malloc(sizeof(X509_POLICY_NODE));
+    node = OPENSSL_malloc(sizeof(*node));
     if (!node)
         return NULL;
     node->data = data;
diff --git a/crypto/x509v3/pcy_tree.c b/crypto/x509v3/pcy_tree.c
index f1bcb05..8870ec2 100644
--- a/crypto/x509v3/pcy_tree.c
+++ b/crypto/x509v3/pcy_tree.c
@@ -218,13 +218,13 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
 
     /* If we get this far initialize the tree */
 
-    tree = OPENSSL_malloc(sizeof(X509_POLICY_TREE));
+    tree = OPENSSL_malloc(sizeof(*tree));
 
     if (!tree)
         return 0;
 
     tree->flags = 0;
-    tree->levels = OPENSSL_malloc(sizeof(X509_POLICY_LEVEL) * n);
+    tree->levels = OPENSSL_malloc(sizeof(*tree->levels) * n);
     tree->nlevel = 0;
     tree->extra_data = NULL;
     tree->auth_policies = NULL;
diff --git a/crypto/x509v3/v3_asid.c b/crypto/x509v3/v3_asid.c
index 34469eb..d7f5848 100644
--- a/crypto/x509v3/v3_asid.c
+++ b/crypto/x509v3/v3_asid.c
@@ -471,7 +471,7 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice)
             ASRange *r;
             switch (a->type) {
             case ASIdOrRange_id:
-                if ((r = OPENSSL_malloc(sizeof(ASRange))) == NULL) {
+                if ((r = OPENSSL_malloc(sizeof(*r))) == NULL) {
                     X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE,
                               ERR_R_MALLOC_FAILURE);
                     goto done;
diff --git a/crypto/x509v3/v3_lib.c b/crypto/x509v3/v3_lib.c
index 3396ff1..c091b04 100644
--- a/crypto/x509v3/v3_lib.c
+++ b/crypto/x509v3/v3_lib.c
@@ -140,7 +140,7 @@ int X509V3_EXT_add_alias(int nid_to, int nid_from)
                   X509V3_R_EXTENSION_NOT_FOUND);
         return 0;
     }
-    if (!(tmpext = OPENSSL_malloc(sizeof(X509V3_EXT_METHOD)))) {
+    if (!(tmpext = OPENSSL_malloc(sizeof(*tmpext)))) {
         X509V3err(X509V3_F_X509V3_EXT_ADD_ALIAS, ERR_R_MALLOC_FAILURE);
         return 0;
     }
diff --git a/crypto/x509v3/v3_purp.c b/crypto/x509v3/v3_purp.c
index 5cee586..ed634cb 100644
--- a/crypto/x509v3/v3_purp.c
+++ b/crypto/x509v3/v3_purp.c
@@ -209,7 +209,7 @@ int X509_PURPOSE_add(int id, int trust, int flags,
     idx = X509_PURPOSE_get_by_id(id);
     /* Need a new entry */
     if (idx == -1) {
-        if (!(ptmp = OPENSSL_malloc(sizeof(X509_PURPOSE)))) {
+        if (!(ptmp = OPENSSL_malloc(sizeof(*ptmp)))) {
             X509V3err(X509V3_F_X509_PURPOSE_ADD, ERR_R_MALLOC_FAILURE);
             return 0;
         }
diff --git a/crypto/x509v3/v3_scts.c b/crypto/x509v3/v3_scts.c
index 2bbc056..31e610d 100644
--- a/crypto/x509v3/v3_scts.c
+++ b/crypto/x509v3/v3_scts.c
@@ -203,7 +203,7 @@ static STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a,
             goto err;
         listlen -= sctlen;
 
-        sct = OPENSSL_malloc(sizeof(SCT));
+        sct = OPENSSL_malloc(sizeof(*sct));
         if (!sct)
             goto err;
         if (!sk_SCT_push(sk, sct)) {
diff --git a/crypto/x509v3/v3_utl.c b/crypto/x509v3/v3_utl.c
index 7142208..a5fda6f 100644
--- a/crypto/x509v3/v3_utl.c
+++ b/crypto/x509v3/v3_utl.c
@@ -88,7 +88,7 @@ int X509V3_add_value(const char *name, const char *value,
         goto err;
     if (value && !(tvalue = BUF_strdup(value)))
         goto err;
-    if (!(vtmp = OPENSSL_malloc(sizeof(CONF_VALUE))))
+    if (!(vtmp = OPENSSL_malloc(sizeof(*vtmp))))
         goto err;
     if (!*extlist && !(*extlist = sk_CONF_VALUE_new_null()))
         goto err;
diff --git a/demos/state_machine/state_machine.c b/demos/state_machine/state_machine.c
index f8a7da8..cd990b2 100644
--- a/demos/state_machine/state_machine.c
+++ b/demos/state_machine/state_machine.c
@@ -114,7 +114,7 @@ void SSLStateMachine_print_error(SSLStateMachine * pMachine,
 SSLStateMachine *SSLStateMachine_new(const char *szCertificateFile,
                                      const char *szKeyFile)
 {
-    SSLStateMachine *pMachine = malloc(sizeof *pMachine);
+    SSLStateMachine *pMachine = malloc(sizeof(*pMachine));
     int n;
 
     die_unless(pMachine);
diff --git a/engines/ccgost/gost_pmeth.c b/engines/ccgost/gost_pmeth.c
index 416f0f9..2537579 100644
--- a/engines/ccgost/gost_pmeth.c
+++ b/engines/ccgost/gost_pmeth.c
@@ -24,7 +24,8 @@ static int pkey_gost_init(EVP_PKEY_CTX *ctx)
 {
     struct gost_pmeth_data *data;
     EVP_PKEY *pkey = EVP_PKEY_CTX_get0_pkey(ctx);
-    data = OPENSSL_malloc(sizeof(struct gost_pmeth_data));
+
+    data = OPENSSL_malloc(sizeof(*data));
     if (!data)
         return 0;
     memset(data, 0, sizeof(struct gost_pmeth_data));
@@ -406,8 +407,8 @@ static int pkey_gost_derive_init(EVP_PKEY_CTX *ctx)
 /* -------- PKEY_METHOD for GOST MAC algorithm --------------------*/
 static int pkey_gost_mac_init(EVP_PKEY_CTX *ctx)
 {
-    struct gost_mac_pmeth_data *data;
-    data = OPENSSL_malloc(sizeof(struct gost_mac_pmeth_data));
+    struct gost_mac_pmeth_data *data = OPENSSL_malloc(sizeof(*data));
+
     if (!data)
         return 0;
     memset(data, 0, sizeof(struct gost_mac_pmeth_data));
diff --git a/engines/e_capi.c b/engines/e_capi.c
index 89e6d1d..33881cd 100644
--- a/engines/e_capi.c
+++ b/engines/e_capi.c
@@ -1441,9 +1441,9 @@ static PCCERT_CONTEXT capi_find_cert(CAPI_CTX * ctx, const char *id,
 static CAPI_KEY *capi_get_key(CAPI_CTX * ctx, const TCHAR *contname,
                               TCHAR *provname, DWORD ptype, DWORD keyspec)
 {
-    CAPI_KEY *key;
     DWORD dwFlags = 0;
-    key = OPENSSL_malloc(sizeof(CAPI_KEY));
+    CAPI_KEY *key = OPENSSL_malloc(sizeof(*key));
+
     if (key == NULL)
         return NULL;
     if (sizeof(TCHAR) == sizeof(char))
@@ -1573,8 +1573,8 @@ void capi_free_key(CAPI_KEY * key)
 
 static CAPI_CTX *capi_ctx_new()
 {
-    CAPI_CTX *ctx;
-    ctx = OPENSSL_malloc(sizeof(CAPI_CTX));
+    CAPI_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));
+
     if (!ctx) {
         CAPIerr(CAPI_F_CAPI_CTX_NEW, ERR_R_MALLOC_FAILURE);
         return NULL;
diff --git a/engines/e_chil.c b/engines/e_chil.c
index 75c15f6..4a173fc 100644
--- a/engines/e_chil.c
+++ b/engines/e_chil.c
@@ -786,7 +786,7 @@ static EVP_PKEY *hwcrhk_load_privkey(ENGINE *eng, const char *key_id,
         goto err;
     }
 #  ifndef OPENSSL_NO_RSA
-    hptr = OPENSSL_malloc(sizeof(HWCryptoHook_RSAKeyHandle));
+    hptr = OPENSSL_malloc(sizeof(*hptr));
     if (!hptr) {
         HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PRIVKEY, ERR_R_MALLOC_FAILURE);
         goto err;
diff --git a/engines/e_gmp.c b/engines/e_gmp.c
index cf01016..dd72759 100644
--- a/engines/e_gmp.c
+++ b/engines/e_gmp.c
@@ -322,9 +322,10 @@ typedef struct st_e_gmp_rsa_ctx {
 static E_GMP_RSA_CTX *e_gmp_get_rsa(RSA *rsa)
 {
     E_GMP_RSA_CTX *hptr = RSA_get_ex_data(rsa, hndidx_rsa);
+
     if (hptr)
         return hptr;
-    hptr = OPENSSL_malloc(sizeof(E_GMP_RSA_CTX));
+    hptr = OPENSSL_malloc(sizeof(*hptr));
     if (!hptr)
         return NULL;
     /*
diff --git a/ssl/bio_ssl.c b/ssl/bio_ssl.c
index 284d3ad..18e7074 100644
--- a/ssl/bio_ssl.c
+++ b/ssl/bio_ssl.c
@@ -101,9 +101,8 @@ BIO_METHOD *BIO_f_ssl(void)
 
 static int ssl_new(BIO *bi)
 {
-    BIO_SSL *bs;
+    BIO_SSL *bs = OPENSSL_malloc(sizeof(*bs));
 
-    bs = OPENSSL_malloc(sizeof(BIO_SSL));
     if (bs == NULL) {
         BIOerr(BIO_F_SSL_NEW, ERR_R_MALLOC_FAILURE);
         return (0);
diff --git a/ssl/d1_both.c b/ssl/d1_both.c
index 3af3ba1..65a3a18 100644
--- a/ssl/d1_both.c
+++ b/ssl/d1_both.c
@@ -170,7 +170,7 @@ static hm_fragment *dtls1_hm_fragment_new(unsigned long frag_len,
     unsigned char *buf = NULL;
     unsigned char *bitmask = NULL;
 
-    frag = OPENSSL_malloc(sizeof(hm_fragment));
+    frag = OPENSSL_malloc(sizeof(*frag));
     if (frag == NULL)
         return NULL;
 
diff --git a/ssl/d1_lib.c b/ssl/d1_lib.c
index 81d532c..3441fc5 100644
--- a/ssl/d1_lib.c
+++ b/ssl/d1_lib.c
@@ -136,11 +136,11 @@ int dtls1_new(SSL *s)
     
     if (!ssl3_new(s))
         return (0);
-    if ((d1 = OPENSSL_malloc(sizeof *d1)) == NULL) {
+    if ((d1 = OPENSSL_malloc(sizeof(*d1))) == NULL) {
         ssl3_free(s);
         return (0);
     }
-    memset(d1, 0, sizeof *d1);
+    memset(d1, 0, sizeof(*d1));
 
     d1->buffered_messages = pqueue_new();
     d1->sent_messages = pqueue_new();
diff --git a/ssl/record/rec_layer_d1.c b/ssl/record/rec_layer_d1.c
index a484c97..2635894 100644
--- a/ssl/record/rec_layer_d1.c
+++ b/ssl/record/rec_layer_d1.c
@@ -127,9 +127,8 @@ int DTLS_RECORD_LAYER_new(RECORD_LAYER *rl)
 {
     DTLS_RECORD_LAYER *d;
     
-    if ((d = OPENSSL_malloc(sizeof *d)) == NULL) {
+    if ((d = OPENSSL_malloc(sizeof(*d))) == NULL)
         return (0);
-    }
 
 
     rl->d = d;
@@ -196,7 +195,7 @@ void DTLS_RECORD_LAYER_clear(RECORD_LAYER *rl)
     unprocessed_rcds = d->unprocessed_rcds.q;
     processed_rcds = d->processed_rcds.q;
     buffered_app_data = d->buffered_app_data.q;
-    memset(d, 0, sizeof *d);
+    memset(d, 0, sizeof(*d));
     d->unprocessed_rcds.q = unprocessed_rcds;
     d->processed_rcds.q = processed_rcds;
     d->buffered_app_data.q = buffered_app_data;
@@ -259,7 +258,7 @@ int dtls1_buffer_record(SSL *s, record_pqueue *queue, unsigned char *priority)
     if (pqueue_size(queue->q) >= 100)
         return 0;
 
-    rdata = OPENSSL_malloc(sizeof(DTLS1_RECORD_DATA));
+    rdata = OPENSSL_malloc(sizeof(*rdata));
     item = pitem_new(priority, rdata);
     if (rdata == NULL || item == NULL) {
         OPENSSL_free(rdata);
diff --git a/ssl/s3_enc.c b/ssl/s3_enc.c
index 45de404..d968a1c 100644
--- a/ssl/s3_enc.c
+++ b/ssl/s3_enc.c
@@ -244,7 +244,7 @@ int ssl3_change_cipher_state(SSL *s, int which)
         if (s->enc_read_ctx != NULL)
             reuse_dd = 1;
         else if ((s->enc_read_ctx =
-                  OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL)
+                  OPENSSL_malloc(sizeof(*s->enc_read_ctx))) == NULL)
             goto err;
         else
             /*
@@ -278,7 +278,7 @@ int ssl3_change_cipher_state(SSL *s, int which)
         if (s->enc_write_ctx != NULL)
             reuse_dd = 1;
         else if ((s->enc_write_ctx =
-                  OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL)
+                  OPENSSL_malloc(sizeof(*s->enc_write_ctx))) == NULL)
             goto err;
         else
             /*
diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c
index e346c22..a962b5c 100644
--- a/ssl/s3_lib.c
+++ b/ssl/s3_lib.c
@@ -3098,9 +3098,9 @@ int ssl3_new(SSL *s)
 {
     SSL3_STATE *s3;
 
-    if ((s3 = OPENSSL_malloc(sizeof *s3)) == NULL)
+    if ((s3 = OPENSSL_malloc(sizeof(*s3))) == NULL)
         goto err;
-    memset(s3, 0, sizeof *s3);
+    memset(s3, 0, sizeof(*s3));
     s->s3 = s3;
     
 #ifndef OPENSSL_NO_SRP
@@ -3137,7 +3137,7 @@ void ssl3_free(SSL *s)
 #ifndef OPENSSL_NO_SRP
     SSL_SRP_CTX_free(s);
 #endif
-    OPENSSL_clear_free(s->s3, sizeof *s->s3);
+    OPENSSL_clear_free(s->s3, sizeof(*s->s3));
     s->s3 = NULL;
 }
 
@@ -3174,7 +3174,7 @@ void ssl3_clear(SSL *s)
         s->s3->alpn_selected = NULL;
     }
 #endif
-    memset(s->s3, 0, sizeof *s->s3);
+    memset(s->s3, 0, sizeof(*s->s3));
     s->s3->init_extra = init_extra;
 
     ssl_free_wbio_buffer(s);
diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c
index cce7f15..c7a2aa9 100644
--- a/ssl/ssl_cert.c
+++ b/ssl/ssl_cert.c
@@ -182,9 +182,8 @@ void ssl_cert_set_default_md(CERT *cert)
 
 CERT *ssl_cert_new(void)
 {
-    CERT *ret;
+    CERT *ret = OPENSSL_malloc(sizeof(*ret));
 
-    ret = OPENSSL_malloc(sizeof(CERT));
     if (ret == NULL) {
         SSLerr(SSL_F_SSL_CERT_NEW, ERR_R_MALLOC_FAILURE);
         return (NULL);
@@ -202,10 +201,9 @@ CERT *ssl_cert_new(void)
 
 CERT *ssl_cert_dup(CERT *cert)
 {
-    CERT *ret;
+    CERT *ret = OPENSSL_malloc(sizeof(*ret));
     int i;
 
-    ret = OPENSSL_malloc(sizeof(CERT));
     if (ret == NULL) {
         SSLerr(SSL_F_SSL_CERT_DUP, ERR_R_MALLOC_FAILURE);
         return (NULL);
@@ -577,13 +575,13 @@ SESS_CERT *ssl_sess_cert_new(void)
 {
     SESS_CERT *ret;
 
-    ret = OPENSSL_malloc(sizeof *ret);
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (ret == NULL) {
         SSLerr(SSL_F_SSL_SESS_CERT_NEW, ERR_R_MALLOC_FAILURE);
         return NULL;
     }
 
-    memset(ret, 0, sizeof *ret);
+    memset(ret, 0, sizeof(*ret));
     ret->peer_key = &(ret->peer_pkeys[SSL_PKEY_RSA_ENC]);
     ret->references = 1;
 
diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c
index a3dca18..0ddb56b 100644
--- a/ssl/ssl_ciph.c
+++ b/ssl/ssl_ciph.c
@@ -499,7 +499,7 @@ static void load_builtin_compressions(void)
             MemCheck_off();
             ssl_comp_methods = sk_SSL_COMP_new(sk_comp_cmp);
             if (ssl_comp_methods != NULL) {
-                comp = OPENSSL_malloc(sizeof(SSL_COMP));
+                comp = OPENSSL_malloc(sizeof(*comp));
                 if (comp != NULL) {
                     comp->method = COMP_zlib();
                     if (comp->method && comp->method->type == NID_undef)
@@ -1452,7 +1452,7 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method, STACK
     fprintf(stderr, "ssl_create_cipher_list() for %d ciphers\n",
             num_of_ciphers);
 #endif                          /* KSSL_DEBUG */
-    co_list = OPENSSL_malloc(sizeof(CIPHER_ORDER) * num_of_ciphers);
+    co_list = OPENSSL_malloc(sizeof(*co_list) * num_of_ciphers);
     if (co_list == NULL) {
         SSLerr(SSL_F_SSL_CREATE_CIPHER_LIST, ERR_R_MALLOC_FAILURE);
         return (NULL);          /* Failure */
@@ -1533,7 +1533,7 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method, STACK
      */
     num_of_group_aliases = OSSL_NELEM(cipher_aliases);
     num_of_alias_max = num_of_ciphers + num_of_group_aliases + 1;
-    ca_list = OPENSSL_malloc(sizeof(SSL_CIPHER *) * num_of_alias_max);
+    ca_list = OPENSSL_malloc(sizeof(*ca_list) * num_of_alias_max);
     if (ca_list == NULL) {
         OPENSSL_free(co_list);
         SSLerr(SSL_F_SSL_CREATE_CIPHER_LIST, ERR_R_MALLOC_FAILURE);
@@ -1933,7 +1933,7 @@ int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm)
     }
 
     MemCheck_off();
-    comp = OPENSSL_malloc(sizeof(SSL_COMP));
+    comp = OPENSSL_malloc(sizeof(*comp));
     if (comp == NULL) {
         MemCheck_on();
         SSLerr(SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD, ERR_R_MALLOC_FAILURE);
diff --git a/ssl/ssl_conf.c b/ssl/ssl_conf.c
index 2d96b11..a14f564 100644
--- a/ssl/ssl_conf.c
+++ b/ssl/ssl_conf.c
@@ -609,9 +609,9 @@ int SSL_CONF_cmd_value_type(SSL_CONF_CTX *cctx, const char *cmd)
 
 SSL_CONF_CTX *SSL_CONF_CTX_new(void)
 {
-    SSL_CONF_CTX *ret;
+    SSL_CONF_CTX *ret = OPENSSL_malloc(sizeof(*ret));
     size_t i;
-    ret = OPENSSL_malloc(sizeof(SSL_CONF_CTX));
+
     if (ret) {
         ret->flags = 0;
         ret->prefix = NULL;
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 4dfd7ab..56d7e6c 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -272,7 +272,7 @@ SSL *SSL_new(SSL_CTX *ctx)
         return (NULL);
     }
 
-    s = OPENSSL_malloc(sizeof(SSL));
+    s = OPENSSL_malloc(sizeof(*s));
     if (s == NULL)
         goto err;
     memset(s, 0, sizeof(SSL));
@@ -1844,7 +1844,7 @@ SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth)
         SSLerr(SSL_F_SSL_CTX_NEW, SSL_R_X509_VERIFICATION_SETUP_PROBLEMS);
         goto err;
     }
-    ret = OPENSSL_malloc(sizeof(SSL_CTX));
+    ret = OPENSSL_malloc(sizeof(*ret));
     if (ret == NULL)
         goto err;
 
diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c
index 1a00c38..b592da4 100644
--- a/ssl/ssl_sess.c
+++ b/ssl/ssl_sess.c
@@ -193,7 +193,7 @@ SSL_SESSION *SSL_SESSION_new(void)
 {
     SSL_SESSION *ss;
 
-    ss = OPENSSL_malloc(sizeof(SSL_SESSION));
+    ss = OPENSSL_malloc(sizeof(*ss));
     if (ss == NULL) {
         SSLerr(SSL_F_SSL_SESSION_NEW, ERR_R_MALLOC_FAILURE);
         return (0);
diff --git a/ssl/t1_enc.c b/ssl/t1_enc.c
index 5c7fb86..47bab99 100644
--- a/ssl/t1_enc.c
+++ b/ssl/t1_enc.c
@@ -375,7 +375,7 @@ int tls1_change_cipher_state(SSL *s, int which)
         if (s->enc_read_ctx != NULL)
             reuse_dd = 1;
         else if ((s->enc_read_ctx =
-                  OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL)
+                  OPENSSL_malloc(sizeof(*s->enc_read_ctx))) == NULL)
             goto err;
         else
             /*
diff --git a/test/Makefile b/test/Makefile
index 74fdf45..97837e1 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -714,15 +714,15 @@ exptest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
 exptest.o: ../include/openssl/ossl_typ.h ../include/openssl/rand.h
 exptest.o: ../include/openssl/safestack.h ../include/openssl/stack.h
 exptest.o: ../include/openssl/symhacks.h exptest.c
-gost2814789test.o: ../engines/ccgost/gost89.h ../include/openssl/asn1.h
-gost2814789test.o: ../include/openssl/bio.h ../include/openssl/buffer.h
-gost2814789test.o: ../include/openssl/conf.h ../include/openssl/crypto.h
-gost2814789test.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
-gost2814789test.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h
-gost2814789test.o: ../include/openssl/engine.h ../include/openssl/err.h
-gost2814789test.o: ../include/openssl/evp.h ../include/openssl/hmac.h
-gost2814789test.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
-gost2814789test.o: ../include/openssl/objects.h
+gost2814789test.o: ../e_os.h ../engines/ccgost/gost89.h
+gost2814789test.o: ../include/openssl/asn1.h ../include/openssl/bio.h
+gost2814789test.o: ../include/openssl/buffer.h ../include/openssl/conf.h
+gost2814789test.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
+gost2814789test.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
+gost2814789test.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
+gost2814789test.o: ../include/openssl/err.h ../include/openssl/evp.h
+gost2814789test.o: ../include/openssl/hmac.h ../include/openssl/lhash.h
+gost2814789test.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
 gost2814789test.o: ../include/openssl/opensslconf.h
 gost2814789test.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
 gost2814789test.o: ../include/openssl/pkcs7.h ../include/openssl/safestack.h
@@ -760,7 +760,7 @@ hmactest.o: ../include/openssl/safestack.h ../include/openssl/stack.h
 hmactest.o: ../include/openssl/symhacks.h hmactest.c
 ideatest.o: ../e_os.h ../include/openssl/e_os2.h ../include/openssl/idea.h
 ideatest.o: ../include/openssl/opensslconf.h ideatest.c
-igetest.o: ../include/openssl/aes.h ../include/openssl/crypto.h
+igetest.o: ../e_os.h ../include/openssl/aes.h ../include/openssl/crypto.h
 igetest.o: ../include/openssl/e_os2.h ../include/openssl/opensslconf.h
 igetest.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
 igetest.o: ../include/openssl/rand.h ../include/openssl/safestack.h
@@ -859,7 +859,8 @@ ssltest.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
 ssltest.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
 ssltest.o: ../include/openssl/x509v3.h ../ssl/record/record.h ../ssl/ssl_locl.h
 ssltest.o: ssltest.c
-testutil.o: testutil.c testutil.h
+testutil.o: ../e_os.h ../include/openssl/e_os2.h
+testutil.o: ../include/openssl/opensslconf.h testutil.c testutil.h
 v3nametest.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 v3nametest.o: ../include/openssl/buffer.h ../include/openssl/conf.h
 v3nametest.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
diff --git a/test/ecdsatest.c b/test/ecdsatest.c
index 6aeff25..377e2c5 100644
--- a/test/ecdsatest.c
+++ b/test/ecdsatest.c
@@ -318,9 +318,7 @@ int test_builtin(BIO *out)
 
     /* get a list of all internal curves */
     crv_len = EC_get_builtin_curves(NULL, 0);
-
-    curves = OPENSSL_malloc(sizeof(EC_builtin_curve) * crv_len);
-
+    curves = OPENSSL_malloc(sizeof(*curves) * crv_len);
     if (curves == NULL) {
         BIO_printf(out, "malloc error\n");
         goto builtin_err;
diff --git a/test/ectest.c b/test/ectest.c
index 4b15708..f04812e 100644
--- a/test/ectest.c
+++ b/test/ectest.c
@@ -1359,9 +1359,7 @@ static void internal_curve_test(void)
     int ok = 1;
 
     crv_len = EC_get_builtin_curves(NULL, 0);
-
-    curves = OPENSSL_malloc(sizeof(EC_builtin_curve) * crv_len);
-
+    curves = OPENSSL_malloc(sizeof(*curves) * crv_len);
     if (curves == NULL)
         return;
 
diff --git a/test/evp_test.c b/test/evp_test.c
index 4b5b9aa..0bba274 100644
--- a/test/evp_test.c
+++ b/test/evp_test.c
@@ -400,7 +400,7 @@ static int process_test(struct evp_test *t, char *buf, int verbose)
             fprintf(stderr, "Duplicate key %s\n", value);
             return 0;
         }
-        key = OPENSSL_malloc(sizeof(struct key_list));
+        key = OPENSSL_malloc(sizeof(*key));
         if (!key)
             return 0;
         key->name = BUF_strdup(value);
@@ -559,7 +559,7 @@ static int digest_test_init(struct evp_test *t, const char *alg)
         }
         return 0;
     }
-    mdat = OPENSSL_malloc(sizeof(struct digest_data));
+    mdat = OPENSSL_malloc(sizeof(*mdat));
     mdat->digest = digest;
     mdat->input = NULL;
     mdat->output = NULL;
@@ -671,7 +671,7 @@ static int cipher_test_init(struct evp_test *t, const char *alg)
         }
         return 0;
     }
-    cdat = OPENSSL_malloc(sizeof(struct cipher_data));
+    cdat = OPENSSL_malloc(sizeof(*cdat));
     cdat->cipher = cipher;
     cdat->enc = -1;
     cdat->key = NULL;
@@ -935,7 +935,7 @@ static int mac_test_init(struct evp_test *t, const char *alg)
     else
         return 0;
 
-    mdat = OPENSSL_malloc(sizeof(struct mac_data));
+    mdat = OPENSSL_malloc(sizeof(*mdat));
     mdat->type = type;
     mdat->alg = NULL;
     mdat->key = NULL;
@@ -1103,7 +1103,7 @@ static int pkey_test_init(struct evp_test *t, const char *name,
         return 1;
     }
 
-    kdata = OPENSSL_malloc(sizeof(struct pkey_data));
+    kdata = OPENSSL_malloc(sizeof(*kdata));
     if (!kdata) {
         EVP_PKEY_free(pkey);
         return 0;


More information about the openssl-commits mailing list