From af38d2832bcd4b2f0397b3f018c3a38fac16d164 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Fri, 3 Dec 2021 17:01:07 +0000 Subject: Convert ASN1_STRING_type_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@ --- src/lib/libcrypto/asn1/asn1_lib.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/asn1/asn1_lib.c b/src/lib/libcrypto/asn1/asn1_lib.c index b04fa3c601..0998b41829 100644 --- a/src/lib/libcrypto/asn1/asn1_lib.c +++ b/src/lib/libcrypto/asn1/asn1_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_lib.c,v 1.46 2021/11/13 20:44:00 schwarze Exp $ */ +/* $OpenBSD: asn1_lib.c,v 1.47 2021/12/03 17:01:07 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -359,18 +359,15 @@ ASN1_STRING_new(void) ASN1_STRING * ASN1_STRING_type_new(int type) { - ASN1_STRING *ret; + ASN1_STRING *a; - ret = malloc(sizeof(ASN1_STRING)); - if (ret == NULL) { + if ((a = calloc(1, sizeof(ASN1_STRING))) == NULL) { ASN1error(ERR_R_MALLOC_FAILURE); - return (NULL); + return NULL; } - ret->length = 0; - ret->type = type; - ret->data = NULL; - ret->flags = 0; - return (ret); + a->type = type; + + return a; } void -- cgit v1.2.3-55-g6feb