]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
MdeModulePkg: Fix potential memory leaks in DxeHttpLib.
[mirror_edk2.git] / MdeModulePkg / Library / DxeHttpLib / DxeHttpLib.c
index 8421caaa703c2cf3af8f5cf4dbae088e23ce0d38..292923875f0707430e55245eed88c50499dda0de 100644 (file)
@@ -523,6 +523,7 @@ HttpUrlGetHostName (
              &ResultLength\r
              );\r
   if (EFI_ERROR (Status)) {\r
+    FreePool (Name);\r
     return Status;\r
   }\r
 \r
@@ -582,6 +583,7 @@ HttpUrlGetIp4 (
              &ResultLength\r
              );\r
   if (EFI_ERROR (Status)) {\r
+    FreePool (Ip4String);\r
     return Status;\r
   }\r
 \r
@@ -657,6 +659,7 @@ HttpUrlGetIp6 (
              &ResultLength\r
              );\r
   if (EFI_ERROR (Status)) {\r
+    FreePool (Ip6String);\r
     return Status;\r
   }\r
   \r
@@ -722,14 +725,15 @@ HttpUrlGetPort (
              &ResultLength\r
              );\r
   if (EFI_ERROR (Status)) {\r
-    return Status;\r
+    goto ON_EXIT;\r
   }\r
 \r
   PortString[ResultLength] = '\0';\r
 \r
   while (Index < ResultLength) {\r
     if (!NET_IS_DIGIT (PortString[Index])) {\r
-      return EFI_INVALID_PARAMETER;\r
+      Status = EFI_INVALID_PARAMETER;\r
+      goto ON_EXIT;\r
     }\r
     Index ++;\r
   }\r
@@ -737,10 +741,14 @@ HttpUrlGetPort (
   Status =  AsciiStrDecimalToUintnS (Url + Parser->FieldData[HTTP_URI_FIELD_PORT].Offset, (CHAR8 **) NULL, &Data);\r
 \r
   if (Data > HTTP_URI_PORT_MAX_NUM) {\r
-    return EFI_INVALID_PARAMETER;\r
+    Status = EFI_INVALID_PARAMETER;\r
+    goto ON_EXIT;\r
   }\r
 \r
   *Port = (UINT16) Data;\r
+\r
+ON_EXIT:\r
+  FreePool (PortString);\r
   return Status;\r
 }\r
 \r
@@ -795,6 +803,7 @@ HttpUrlGetPath (
              &ResultLength\r
              );\r
   if (EFI_ERROR (Status)) {\r
+    FreePool (PathStr);\r
     return Status;\r
   }\r
 \r