public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Paulo Alcantara <pcacjr@gmail.com>
To: edk2-devel@lists.01.org
Cc: Paulo Alcantara <pcacjr@gmail.com>,
	Star Zeng <star.zeng@intel.com>, Eric Dong <eric.dong@intel.com>
Subject: [PATCH] MdeModulePkg/DxeHttpLib: Fix potential memory leaks
Date: Sun, 21 May 2017 10:42:17 -0300	[thread overview]
Message-ID: <20170521134217.6667-1-pcacjr@gmail.com> (raw)

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Paulo Alcantara <pcacjr@gmail.com>
---
 MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
index 8421caa..0523227 100644
--- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
+++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
@@ -523,6 +523,7 @@ HttpUrlGetHostName (
              &ResultLength
              );
   if (EFI_ERROR (Status)) {
+    FreePool (Name);
     return Status;
   }
 
@@ -582,6 +583,7 @@ HttpUrlGetIp4 (
              &ResultLength
              );
   if (EFI_ERROR (Status)) {
+    FreePool (Ip4String);
     return Status;
   }
 
@@ -657,6 +659,7 @@ HttpUrlGetIp6 (
              &ResultLength
              );
   if (EFI_ERROR (Status)) {
+    FreePool (Ip6String);
     return Status;
   }
   
@@ -722,14 +725,15 @@ HttpUrlGetPort (
              &ResultLength
              );
   if (EFI_ERROR (Status)) {
-    return Status;
+    goto Error;
   }
 
   PortString[ResultLength] = '\0';
 
   while (Index < ResultLength) {
     if (!NET_IS_DIGIT (PortString[Index])) {
-      return EFI_INVALID_PARAMETER;
+      Status = EFI_INVALID_PARAMETER;
+      goto Error;
     }
     Index ++;
   }
@@ -737,10 +741,14 @@ HttpUrlGetPort (
   Status =  AsciiStrDecimalToUintnS (Url + Parser->FieldData[HTTP_URI_FIELD_PORT].Offset, (CHAR8 **) NULL, &Data);
 
   if (Data > HTTP_URI_PORT_MAX_NUM) {
-    return EFI_INVALID_PARAMETER;
+    Status = EFI_INVALID_PARAMETER;
+    goto Error;
   }
 
   *Port = (UINT16) Data;
+
+Error:
+  FreePool (PortString);
   return Status;
 }
 
@@ -795,6 +803,7 @@ HttpUrlGetPath (
              &ResultLength
              );
   if (EFI_ERROR (Status)) {
+    FreePool (PathStr);
     return Status;
   }
 
-- 
2.9.4



             reply	other threads:[~2017-05-21 13:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-21 13:42 Paulo Alcantara [this message]
2017-05-22  2:55 ` [PATCH] MdeModulePkg/DxeHttpLib: Fix potential memory leaks Wu, Jiaxin
2017-05-22 11:52 ` [PATCH v2] " Paulo Alcantara
2017-05-23  2:10   ` Wu, Jiaxin
2017-06-05  7:15   ` Ye, Ting

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170521134217.6667-1-pcacjr@gmail.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox