From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 543CC21A16E4A for ; Sun, 21 May 2017 19:55:58 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 May 2017 19:55:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,377,1491289200"; d="scan'208";a="264730734" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga004.fm.intel.com with ESMTP; 21 May 2017 19:55:57 -0700 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 21 May 2017 19:55:57 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 21 May 2017 19:55:57 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.117]) by SHSMSX104.ccr.corp.intel.com ([10.239.4.70]) with mapi id 14.03.0319.002; Mon, 22 May 2017 10:55:56 +0800 From: "Wu, Jiaxin" To: Paulo Alcantara , "edk2-devel@lists.01.org" CC: "Dong, Eric" , "Zeng, Star" , "Fu, Siyuan" Thread-Topic: [edk2] [PATCH] MdeModulePkg/DxeHttpLib: Fix potential memory leaks Thread-Index: AQHS0jgiE7/7AD53/k2wgxV29ofw3qH/p6oA Date: Mon, 22 May 2017 02:55:55 +0000 Message-ID: <895558F6EA4E3B41AC93A00D163B7274162CBF68@SHSMSX103.ccr.corp.intel.com> References: <20170521134217.6667-1-pcacjr@gmail.com> In-Reply-To: <20170521134217.6667-1-pcacjr@gmail.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYjVmZTBkZjEtYTVkNC00MzZiLTljMzItZWVjMDViNTgxZDNhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX1BVQkxJQyJ9XX1dfSwiU3ViamVjdExhYmVscyI6W10sIlRNQ1ZlcnNpb24iOiIxNS45LjYuNiIsIlRydXN0ZWRMYWJlbEhhc2giOiJrVUF1UUozZHFXK0hrekdJZGw3SGdDeFcxNDVuUDVBUVNuYnNYc21TbVEwPSJ9 x-ctpclassification: CTP_PUBLIC 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] 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: Mon, 22 May 2017 02:55:58 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello Paulo, Thanks your contribution. Only one small comments: We'd better use "ON_EXIT" instead of "Error" in HttpUrlGetPort() since the = PortString should always be freed. Others is good to me. Reviewed-by: Wu Jiaxin > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Pa= ulo > Alcantara > Sent: Sunday, May 21, 2017 9:42 PM > To: edk2-devel@lists.01.org > Cc: Dong, Eric ; Zeng, Star > Subject: [edk2] [PATCH] 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..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; > } >=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 Error; > } >=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 Error; > } > 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 Error; > } >=20 > *Port =3D (UINT16) Data; > + > +Error: > + 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