Commit a2d0baa2 authored by FdaSilvaYY's avatar FdaSilvaYY Committed by Rich Salz
Browse files

GH678: Add a few more zalloc



Remove some duplicated NULL/zero init.

Signed-off-by: default avatarRich Salz <rsalz@openssl.org>
Reviewed-by: default avatarTim Hudson <tjh@openssl.org>
parent cbb259ca
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -271,12 +271,6 @@ BIO_CONNECT *BIO_CONNECT_new(void)
        return (NULL);
    ret->state = BIO_CONN_S_BEFORE;
    ret->connect_family = BIO_FAMILY_IPANY;
    ret->param_hostname = NULL;
    ret->param_service = NULL;
    ret->info_callback = NULL;
    ret->connect_mode = 0;
    ret->addr_first = NULL;
    ret->addr_iter = NULL;
    return (ret);
}

+1 −1
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ BN_RECP_CTX *BN_RECP_CTX_new(void)
{
    BN_RECP_CTX *ret;

    if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
    if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL)
        return (NULL);

    BN_RECP_CTX_init(ret);
+3 −3
Original line number Diff line number Diff line
@@ -1816,13 +1816,13 @@ 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));
    NISTP256_PRE_COMP *ret = OPENSSL_zalloc(sizeof(*ret));

    if (ret == NULL) {
        ECerr(EC_F_NISTP256_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);
        return ret;
    }
    memset(ret->g_pre_comp, 0, sizeof(ret->g_pre_comp));

    ret->references = 1;
    return ret;
}
+0 −2
Original line number Diff line number Diff line
@@ -1395,8 +1395,6 @@ static NISTZ256_PRE_COMP *ecp_nistz256_pre_comp_new(const EC_GROUP *group)

    ret->group = group;
    ret->w = 6;                 /* default */
    ret->precomp = NULL;
    ret->precomp_storage = NULL;
    ret->references = 1;
    return ret;
}
+1 −6
Original line number Diff line number Diff line
@@ -186,9 +186,8 @@ int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b)

EVP_PKEY *EVP_PKEY_new(void)
{
    EVP_PKEY *ret;
    EVP_PKEY *ret = OPENSSL_zalloc(sizeof(*ret));

    ret = OPENSSL_malloc(sizeof(*ret));
    if (ret == NULL) {
        EVPerr(EVP_F_EVP_PKEY_NEW, ERR_R_MALLOC_FAILURE);
        return (NULL);
@@ -196,10 +195,6 @@ EVP_PKEY *EVP_PKEY_new(void)
    ret->type = EVP_PKEY_NONE;
    ret->save_type = EVP_PKEY_NONE;
    ret->references = 1;
    ret->ameth = NULL;
    ret->engine = NULL;
    ret->pkey.ptr = NULL;
    ret->attributes = NULL;
    ret->save_parameters = 1;
    return (ret);
}
Loading