diff options
| author | jsing <> | 2021-12-03 17:01:07 +0000 |
|---|---|---|
| committer | jsing <> | 2021-12-03 17:01:07 +0000 |
| commit | af38d2832bcd4b2f0397b3f018c3a38fac16d164 (patch) | |
| tree | 01b6610001cfb90952051cf5bf66659b81a0f8c0 /src/lib | |
| parent | f162875e92493c34bc254b18bbb87884c6da2250 (diff) | |
| download | openbsd-af38d2832bcd4b2f0397b3f018c3a38fac16d164.tar.gz openbsd-af38d2832bcd4b2f0397b3f018c3a38fac16d164.tar.bz2 openbsd-af38d2832bcd4b2f0397b3f018c3a38fac16d164.zip | |
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@
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/libcrypto/asn1/asn1_lib.c | 17 |
1 files changed, 7 insertions, 10 deletions
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 @@ | |||
| 1 | /* $OpenBSD: asn1_lib.c,v 1.46 2021/11/13 20:44:00 schwarze Exp $ */ | 1 | /* $OpenBSD: asn1_lib.c,v 1.47 2021/12/03 17:01:07 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -359,18 +359,15 @@ ASN1_STRING_new(void) | |||
| 359 | ASN1_STRING * | 359 | ASN1_STRING * |
| 360 | ASN1_STRING_type_new(int type) | 360 | ASN1_STRING_type_new(int type) |
| 361 | { | 361 | { |
| 362 | ASN1_STRING *ret; | 362 | ASN1_STRING *a; |
| 363 | 363 | ||
| 364 | ret = malloc(sizeof(ASN1_STRING)); | 364 | if ((a = calloc(1, sizeof(ASN1_STRING))) == NULL) { |
| 365 | if (ret == NULL) { | ||
| 366 | ASN1error(ERR_R_MALLOC_FAILURE); | 365 | ASN1error(ERR_R_MALLOC_FAILURE); |
| 367 | return (NULL); | 366 | return NULL; |
| 368 | } | 367 | } |
| 369 | ret->length = 0; | 368 | a->type = type; |
| 370 | ret->type = type; | 369 | |
| 371 | ret->data = NULL; | 370 | return a; |
| 372 | ret->flags = 0; | ||
| 373 | return (ret); | ||
| 374 | } | 371 | } |
| 375 | 372 | ||
| 376 | void | 373 | void |
