]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg/HttpBootDxe: Avoid the potential memory leak when eror happen.
authorJiaxin Wu <jiaxin.wu@intel.com>
Thu, 21 Dec 2017 05:32:20 +0000 (13:32 +0800)
committerJiaxin Wu <jiaxin.wu@intel.com>
Fri, 22 Dec 2017 07:50:58 +0000 (15:50 +0800)
Cc: Wang Fan <fan.wang@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Wang Fan <fan.wang@intel.com>
NetworkPkg/HttpBootDxe/HttpBootDhcp4.c
NetworkPkg/HttpBootDxe/HttpBootImpl.c

index a8cee04c256c1c5657255dcc02c529e7f46cbe34..421ce6eda40e9db42c209c89e0215f1c383fffcd 100644 (file)
@@ -422,6 +422,9 @@ HttpBootParseDhcp4Packet (
     if (!IsProxyOffer) {\r
       OfferType = IsDnsOffer ? HttpOfferTypeDhcpDns : HttpOfferTypeDhcpOnly;\r
     } else {\r
+      if (Cache4->UriParser != NULL) {\r
+        FreePool (Cache4->UriParser);\r
+      }\r
       return EFI_DEVICE_ERROR;\r
     }\r
   }\r
index 7f0616dafc065dd2db0b131078ee976848612c86..d4b46a6e4a0bac6315bea073cc5e2392ce713973 100644 (file)
@@ -122,8 +122,9 @@ HttpBootStart (
   UINTN                Index;\r
   EFI_STATUS           Status;\r
   CHAR8                *Uri;\r
-  \r
 \r
+  Uri = NULL;\r
+  \r
   if (Private == NULL || FilePath == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -154,6 +155,9 @@ HttpBootStart (
       //\r
       Status = HttpBootStop (Private);\r
       if (EFI_ERROR (Status)) {\r
+        if (Uri != NULL) {\r
+          FreePool (Uri);\r
+        }\r
         return Status;\r
       }\r
     } else {\r