apps: fix Coverity 1472670 & 1472685: resource leaks
authorPauli <ppzgs1@gmail.com>
Thu, 18 Mar 2021 03:04:21 +0000 (13:04 +1000)
committerPauli <ppzgs1@gmail.com>
Sat, 20 Mar 2021 00:08:00 +0000 (10:08 +1000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14596)

apps/ocsp.c

index e77c90f041d843b2711144f4bf2c33f1c4f00254..bd509d98a760e8d6513d9d0ebd483402ddd1b401 100644 (file)
@@ -241,14 +241,10 @@ int ocsp_main(int argc, char **argv)
     unsigned long sign_flags = 0, verify_flags = 0, rflags = 0;
     OPTION_CHOICE o;
 
-    reqnames = sk_OPENSSL_STRING_new_null();
-    if (reqnames == NULL)
+    if ((reqnames = sk_OPENSSL_STRING_new_null()) == NULL
+            || (ids = sk_OCSP_CERTID_new_null()) == NULL
+            || (vpm = X509_VERIFY_PARAM_new()) == NULL)
         goto end;
-    ids = sk_OCSP_CERTID_new_null();
-    if (ids == NULL)
-        goto end;
-    if ((vpm = X509_VERIFY_PARAM_new()) == NULL)
-        return 1;
 
     prog = opt_init(argc, argv, ocsp_options);
     while ((o = opt_next()) != OPT_EOF) {