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 <[email protected]>


> -----Original Message-----
> From: edk2-devel [mailto:[email protected]] On Behalf Of Paulo
> Alcantara
> Sent: Sunday, May 21, 2017 9:42 PM
> To: [email protected]
> Cc: Dong, Eric <[email protected]>; Zeng, Star <[email protected]>
> Subject: [edk2] [PATCH] MdeModulePkg/DxeHttpLib: Fix potential memory
> leaks
> 
> Cc: Star Zeng <[email protected]>
> Cc: Eric Dong <[email protected]>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Paulo Alcantara <[email protected]>
> ---
>  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
> 
> _______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to