]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/DxeHttpLib: Avoid the potential memory leak when error happen.
authorJiaxin Wu <jiaxin.wu@intel.com>
Thu, 21 Dec 2017 06:36:12 +0000 (14:36 +0800)
committerJiaxin Wu <jiaxin.wu@intel.com>
Wed, 27 Dec 2017 08:28:40 +0000 (16:28 +0800)
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wang Fan <fan.wang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c

index 915b81d17c1a68c22770dc81ee1b1cdd798f7bbd..774bf7d7e56a39fd3b9e4226b16c264f8e4ef2eb 100644 (file)
@@ -372,6 +372,8 @@ HttpParseUrl (
   BOOLEAN               FoundAt;\r
   EFI_STATUS            Status;\r
   HTTP_URL_PARSER       *Parser;\r
+\r
+  Parser = NULL;\r
   \r
   if (Url == NULL || Length == 0 || UrlParser == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -402,6 +404,7 @@ HttpParseUrl (
 \r
     switch (State) {\r
     case UrlParserStateMax:\r
+      FreePool (Parser);\r
       return EFI_INVALID_PARAMETER;\r
       \r
     case UrlParserSchemeColon:\r
@@ -464,6 +467,7 @@ HttpParseUrl (
   if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_AUTHORITY)) != 0) {\r
     Status = NetHttpParseAuthority (Url, FoundAt, Parser);\r
     if (EFI_ERROR (Status)) {\r
+      FreePool (Parser);\r
       return Status;\r
     }\r
   }\r
@@ -1528,6 +1532,7 @@ HttpSetFieldNameAndValue (
   FieldValueSize = AsciiStrSize (FieldValue);\r
   HttpHeader->FieldValue = AllocateZeroPool (FieldValueSize);\r
   if (HttpHeader->FieldValue == NULL) {\r
+    FreePool (HttpHeader->FieldName);\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
   CopyMem (HttpHeader->FieldValue, FieldValue, FieldValueSize);\r