From: jsing Date: Fri, 3 Dec 2021 16:58:11 +0000 (+0000) Subject: Convert ASN1_OBJECT_new() to calloc(). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=98acf57e48eefefa2988369df2f116c8706fde66;p=openbsd Convert ASN1_OBJECT_new() to calloc(). Rather than using malloc() and then initialising all struct members, use calloc() and only initialise the single non-zero value member. ok schwarze@ tb@ --- diff --git a/lib/libcrypto/asn1/a_object.c b/lib/libcrypto/asn1/a_object.c index 8600f80474e..9b3bae0442e 100644 --- a/lib/libcrypto/asn1/a_object.c +++ b/lib/libcrypto/asn1/a_object.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_object.c,v 1.32 2021/05/01 13:16:30 tb Exp $ */ +/* $OpenBSD: a_object.c,v 1.33 2021/12/03 16:58:11 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -354,20 +354,15 @@ err: ASN1_OBJECT * ASN1_OBJECT_new(void) { - ASN1_OBJECT *ret; + ASN1_OBJECT *a; - ret = malloc(sizeof(ASN1_OBJECT)); - if (ret == NULL) { + if ((a = calloc(1, sizeof(ASN1_OBJECT))) == NULL) { ASN1error(ERR_R_MALLOC_FAILURE); return (NULL); } - ret->length = 0; - ret->data = NULL; - ret->nid = 0; - ret->sn = NULL; - ret->ln = NULL; - ret->flags = ASN1_OBJECT_FLAG_DYNAMIC; - return (ret); + a->flags = ASN1_OBJECT_FLAG_DYNAMIC; + + return a; } void