From: Matt Caswell Date: Tue, 21 Mar 2017 09:07:17 +0000 (+0000) Subject: Fix error paths in ASN1_TIME_to_generalizedtime X-Git-Tag: OpenSSL_1_0_2l~37 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ffcdb0e6efb6fb7033b2cd29e8cca2e2fe355c14;p=oweals%2Fopenssl.git Fix error paths in ASN1_TIME_to_generalizedtime We should not write to |out| in error cases, so we should defer doing this until the "done" block. Reviewed-by: Rich Salz (Merged from https://github.com/openssl/openssl/pull/3002) --- diff --git a/crypto/asn1/a_time.c b/crypto/asn1/a_time.c index 6074325816..0eeb79cd42 100644 --- a/crypto/asn1/a_time.c +++ b/crypto/asn1/a_time.c @@ -147,10 +147,9 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, if (!out || !*out) { if (!(ret = ASN1_GENERALIZEDTIME_new())) goto err; - if (out) - *out = ret; - } else + } else { ret = *out; + } /* If already GeneralizedTime just copy across */ if (t->type == V_ASN1_GENERALIZEDTIME) {