summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Library/DxeHttpLib
diff options
context:
space:
mode:
authorJiaxin Wu <jiaxin.wu@intel.com>2017-12-21 14:36:12 +0800
committerJiaxin Wu <jiaxin.wu@intel.com>2017-12-27 16:28:40 +0800
commitf5168b847d8d374fc0206603c7479a3c7ed5fbb0 (patch)
tree61f016657545668b6fe404287f76dc071ab4e9b2 /MdeModulePkg/Library/DxeHttpLib
parentb2a73b5b3cc6e3edc660384cd0d3d40fe04153b0 (diff)
downloadedk2-f5168b847d8d374fc0206603c7479a3c7ed5fbb0.tar.gz
edk2-f5168b847d8d374fc0206603c7479a3c7ed5fbb0.tar.bz2
edk2-f5168b847d8d374fc0206603c7479a3c7ed5fbb0.zip
MdeModulePkg/DxeHttpLib: Avoid the potential memory leak when error happen.
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>
Diffstat (limited to 'MdeModulePkg/Library/DxeHttpLib')
-rw-r--r--MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
index 915b81d17c..774bf7d7e5 100644
--- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
+++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
@@ -372,6 +372,8 @@ HttpParseUrl (
BOOLEAN FoundAt;
EFI_STATUS Status;
HTTP_URL_PARSER *Parser;
+
+ Parser = NULL;
if (Url == NULL || Length == 0 || UrlParser == NULL) {
return EFI_INVALID_PARAMETER;
@@ -402,6 +404,7 @@ HttpParseUrl (
switch (State) {
case UrlParserStateMax:
+ FreePool (Parser);
return EFI_INVALID_PARAMETER;
case UrlParserSchemeColon:
@@ -464,6 +467,7 @@ HttpParseUrl (
if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_AUTHORITY)) != 0) {
Status = NetHttpParseAuthority (Url, FoundAt, Parser);
if (EFI_ERROR (Status)) {
+ FreePool (Parser);
return Status;
}
}
@@ -1528,6 +1532,7 @@ HttpSetFieldNameAndValue (
FieldValueSize = AsciiStrSize (FieldValue);
HttpHeader->FieldValue = AllocateZeroPool (FieldValueSize);
if (HttpHeader->FieldValue == NULL) {
+ FreePool (HttpHeader->FieldName);
return EFI_OUT_OF_RESOURCES;
}
CopyMem (HttpHeader->FieldValue, FieldValue, FieldValueSize);