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 12:51:34 +0000 (12:51 +0000)
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5444)

apps/ca.c

index 743e48185b8a67676c4ff9aa436d7af2f9c0a528..d530cf5cd71437eecf6f6ba6ba6df6274839644e 100644 (file)
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -1861,11 +1861,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);