From b5ee39e50db98b0270f3355e1ca6bf45a3a00fba Mon Sep 17 00:00:00 2001 From: tb Date: Wed, 1 Nov 2023 20:14:51 +0000 Subject: [PATCH] Split X509_ALGOR_set0_obj() out of X509_ALGOR_set0() ok jsing --- lib/libcrypto/asn1/x_algor.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/libcrypto/asn1/x_algor.c b/lib/libcrypto/asn1/x_algor.c index 0a80b863dea..d91efe93237 100644 --- a/lib/libcrypto/asn1/x_algor.c +++ b/lib/libcrypto/asn1/x_algor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_algor.c,v 1.31 2023/10/11 13:22:11 tb Exp $ */ +/* $OpenBSD: x_algor.c,v 1.32 2023/11/01 20:14:51 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -149,6 +149,15 @@ X509_ALGOR_dup(X509_ALGOR *x) return ASN1_item_dup(&X509_ALGOR_it, x); } +static int +X509_ALGOR_set0_obj(X509_ALGOR *alg, ASN1_OBJECT *aobj) +{ + ASN1_OBJECT_free(alg->algorithm); + alg->algorithm = aobj; + + return 1; +} + int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval) { @@ -167,8 +176,8 @@ X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval) ASN1_TYPE_set(alg->parameter, ptype, pval); } - ASN1_OBJECT_free(alg->algorithm); - alg->algorithm = aobj; + if (!X509_ALGOR_set0_obj(alg, aobj)) + return 0; return 1; } -- 2.20.1