From f83b85fb0f46f7a3e92651f1e5eb7b1081fb8650 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Tue, 26 Apr 2016 18:45:46 +0100 Subject: [PATCH] Ensure an ASN1_OBJECT is freed in error paths Reviewed-by: Richard Levitte --- apps/x509.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/x509.c b/apps/x509.c index 56c6fcca6a..64197665d0 100644 --- a/apps/x509.c +++ b/apps/x509.c @@ -145,7 +145,7 @@ OPTIONS x509_options[] = { int x509_main(int argc, char **argv) { ASN1_INTEGER *sno = NULL; - ASN1_OBJECT *objtmp; + ASN1_OBJECT *objtmp = NULL; BIO *out = NULL; CONF *extconf = NULL; EVP_PKEY *Upkey = NULL, *CApkey = NULL, *fkey = NULL; @@ -277,6 +277,7 @@ int x509_main(int argc, char **argv) if (trust == NULL && (trust = sk_ASN1_OBJECT_new_null()) == NULL) goto end; sk_ASN1_OBJECT_push(trust, objtmp); + objtmp = NULL; trustout = 1; break; case OPT_ADDREJECT: @@ -290,6 +291,7 @@ int x509_main(int argc, char **argv) && (reject = sk_ASN1_OBJECT_new_null()) == NULL) goto end; sk_ASN1_OBJECT_push(reject, objtmp); + objtmp = NULL; trustout = 1; break; case OPT_SETALIAS: @@ -590,6 +592,7 @@ int x509_main(int argc, char **argv) objtmp = sk_ASN1_OBJECT_value(trust, i); X509_add1_trust_object(x, objtmp); } + objtmp = NULL; } if (reject) { @@ -597,6 +600,7 @@ int x509_main(int argc, char **argv) objtmp = sk_ASN1_OBJECT_value(reject, i); X509_add1_reject_object(x, objtmp); } + objtmp = NULL; } if (num) { @@ -885,6 +889,7 @@ int x509_main(int argc, char **argv) ASN1_INTEGER_free(sno); sk_ASN1_OBJECT_pop_free(trust, ASN1_OBJECT_free); sk_ASN1_OBJECT_pop_free(reject, ASN1_OBJECT_free); + ASN1_OBJECT_free(objtmp); OPENSSL_free(passin); return (ret); } -- 2.25.1