NetworkPkg/HttpDxe: use error handler epilogue in TlsConfigCertificate()
authorLaszlo Ersek <lersek@redhat.com>
Thu, 22 Mar 2018 09:31:55 +0000 (10:31 +0100)
committerLaszlo Ersek <lersek@redhat.com>
Wed, 28 Mar 2018 11:07:29 +0000 (13:07 +0200)
Introduce a FreeCACert label near the end of the function, so that we can
keep the FreePool(CACert) statement centralized for error and success
exits.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
NetworkPkg/HttpDxe/HttpsSupport.c

index 5105a2014c25147a209d8d2f326f250ec81e1740..9103987a0e4c8ead2d236212c68eeb6ba669e389 100644 (file)
@@ -425,9 +425,8 @@ TlsConfigCertificate (
     // GetVariable still error or the variable is corrupted.\r
     // Fall back to the default value.\r
     //\r
     // GetVariable still error or the variable is corrupted.\r
     // Fall back to the default value.\r
     //\r
-    FreePool (CACert);\r
-\r
-    return EFI_NOT_FOUND;\r
+    Status = EFI_NOT_FOUND;\r
+    goto FreeCACert;\r
   }\r
 \r
   ASSERT (CACert != NULL);\r
   }\r
 \r
   ASSERT (CACert != NULL);\r
@@ -451,8 +450,7 @@ TlsConfigCertificate (
                                                  CertList->SignatureSize - sizeof (Cert->SignatureOwner)\r
                                                  );\r
       if (EFI_ERROR (Status)) {\r
                                                  CertList->SignatureSize - sizeof (Cert->SignatureOwner)\r
                                                  );\r
       if (EFI_ERROR (Status)) {\r
-        FreePool (CACert);\r
-        return Status;\r
+        goto FreeCACert;\r
       }\r
 \r
       Cert = (EFI_SIGNATURE_DATA *) ((UINT8 *) Cert + CertList->SignatureSize);\r
       }\r
 \r
       Cert = (EFI_SIGNATURE_DATA *) ((UINT8 *) Cert + CertList->SignatureSize);\r
@@ -462,6 +460,7 @@ TlsConfigCertificate (
     CertList = (EFI_SIGNATURE_LIST *) ((UINT8 *) CertList + CertList->SignatureListSize);\r
   }\r
 \r
     CertList = (EFI_SIGNATURE_LIST *) ((UINT8 *) CertList + CertList->SignatureListSize);\r
   }\r
 \r
+FreeCACert:\r
   FreePool (CACert);\r
   return Status;\r
 }\r
   FreePool (CACert);\r
   return Status;\r
 }\r