From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A6C8921A16EF9 for ; Mon, 22 May 2017 19:11:00 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP; 22 May 2017 19:11:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,380,1491289200"; d="scan'208";a="105696978" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga006.fm.intel.com with ESMTP; 22 May 2017 19:11:00 -0700 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 22 May 2017 19:11:00 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 22 May 2017 19:10:59 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.117]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.224]) with mapi id 14.03.0319.002; Tue, 23 May 2017 10:10:57 +0800 From: "Wu, Jiaxin" To: Paulo Alcantara , "edk2-devel@lists.01.org" CC: "Dong, Eric" , "Zeng, Star" Thread-Topic: [edk2] [PATCH v2] MdeModulePkg/DxeHttpLib: Fix potential memory leaks Thread-Index: AQHS0vHk8WibCJQPHE6N0Q6HZnhYjqIBJYNA Date: Tue, 23 May 2017 02:10:56 +0000 Message-ID: <895558F6EA4E3B41AC93A00D163B7274162CC608@SHSMSX103.ccr.corp.intel.com> References: <20170521134217.6667-1-pcacjr@gmail.com> <20170522115211.7133-1-pcacjr@gmail.com> In-Reply-To: <20170522115211.7133-1-pcacjr@gmail.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDRlMGQzZDQtYTdiNy00YTNlLTg3OTEtZTU4Y2JjMjgxNTcxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IjRibjZUNWVaUkJTTlczZEU4Zkg5a01OT3lFZlk3d1pMcHBYYTZPciszcms9In0= x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2] MdeModulePkg/DxeHttpLib: Fix potential memory leaks X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 May 2017 02:11:00 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Wu Jiaxin > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Pa= ulo > Alcantara > Sent: Monday, May 22, 2017 7:52 PM > To: edk2-devel@lists.01.org > Cc: Dong, Eric ; Zeng, Star > Subject: [edk2] [PATCH v2] MdeModulePkg/DxeHttpLib: Fix potential memory > leaks >=20 > Cc: Star Zeng > Cc: Eric Dong > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Paulo Alcantara > --- > MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 15 ++++++++++++--- > 1 file changed, 12 insertions(+), 3 deletions(-) >=20 > diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c > b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c > index 8421caa..2929238 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; > } >=20 > @@ -582,6 +583,7 @@ HttpUrlGetIp4 ( > &ResultLength > ); > if (EFI_ERROR (Status)) { > + FreePool (Ip4String); > return Status; > } >=20 > @@ -657,6 +659,7 @@ HttpUrlGetIp6 ( > &ResultLength > ); > if (EFI_ERROR (Status)) { > + FreePool (Ip6String); > return Status; > } >=20 > @@ -722,14 +725,15 @@ HttpUrlGetPort ( > &ResultLength > ); > if (EFI_ERROR (Status)) { > - return Status; > + goto ON_EXIT; > } >=20 > PortString[ResultLength] =3D '\0'; >=20 > while (Index < ResultLength) { > if (!NET_IS_DIGIT (PortString[Index])) { > - return EFI_INVALID_PARAMETER; > + Status =3D EFI_INVALID_PARAMETER; > + goto ON_EXIT; > } > Index ++; > } > @@ -737,10 +741,14 @@ HttpUrlGetPort ( > Status =3D AsciiStrDecimalToUintnS (Url + Parser- > >FieldData[HTTP_URI_FIELD_PORT].Offset, (CHAR8 **) NULL, &Data); >=20 > if (Data > HTTP_URI_PORT_MAX_NUM) { > - return EFI_INVALID_PARAMETER; > + Status =3D EFI_INVALID_PARAMETER; > + goto ON_EXIT; > } >=20 > *Port =3D (UINT16) Data; > + > +ON_EXIT: > + FreePool (PortString); > return Status; > } >=20 > @@ -795,6 +803,7 @@ HttpUrlGetPath ( > &ResultLength > ); > if (EFI_ERROR (Status)) { > + FreePool (PathStr); > return Status; > } >=20 > -- > 2.9.4 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel