Fix a memory leak in the ca application
authorMatt Caswell <matt@openssl.org>
Wed, 14 Mar 2018 14:32:48 +0000 (14:32 +0000)
committerMatt Caswell <matt@openssl.org>
Thu, 15 Mar 2018 13:32:23 +0000 (13:32 +0000)
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5627)

apps/ca.c

index 8596b5f520980a8b7eac27d897cfcca81f2a4dd7..02186a12ecbda12b4177d1a15fa7ed3696778e63 100644 (file)
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -1864,11 +1864,11 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
     irow = NULL;
     ok = 1;
  end:
-    if (irow != NULL) {
+    if (ok != 1) {
         for (i = 0; i < DB_NUMBER; i++)
             OPENSSL_free(row[i]);
-        OPENSSL_free(irow);
     }
+    OPENSSL_free(irow);
 
     X509_NAME_free(CAname);
     X509_NAME_free(subject);