From: jsing Date: Fri, 3 Dec 2021 17:10:49 +0000 (+0000) Subject: Convert ASN1_PCTX_new() to calloc(). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=ba6cd9e8581f5ac0f9c00690c35e19b31d40cfee;p=openbsd Convert ASN1_PCTX_new() to calloc(). Rather than using malloc() and then initialising all struct members to zero values, use calloc(). ok schwarze@ tb@ --- diff --git a/lib/libcrypto/asn1/tasn_prn.c b/lib/libcrypto/asn1/tasn_prn.c index 4c676d8c04f..54ec56ec25e 100644 --- a/lib/libcrypto/asn1/tasn_prn.c +++ b/lib/libcrypto/asn1/tasn_prn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_prn.c,v 1.21 2020/03/24 10:46:38 inoguchi Exp $ */ +/* $OpenBSD: tasn_prn.c,v 1.22 2021/12/03 17:10:49 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -84,18 +84,14 @@ ASN1_PCTX default_pctx = { ASN1_PCTX * ASN1_PCTX_new(void) { - ASN1_PCTX *ret; - ret = malloc(sizeof(ASN1_PCTX)); - if (ret == NULL) { + ASN1_PCTX *p; + + if ((p = calloc(1, sizeof(ASN1_PCTX))) == NULL) { ASN1error(ERR_R_MALLOC_FAILURE); return NULL; } - ret->flags = 0; - ret->nm_flags = 0; - ret->cert_flags = 0; - ret->oid_flags = 0; - ret->str_flags = 0; - return ret; + + return p; } void