Colin,

Thank you for reporting this.
I have added it to the list things to fix.

It will be addressed ASAP.

Sincerely,
Daryl McDaniel

> -----Original Message-----
> From: Colin King [mailto:[email protected]]
> Sent: Tuesday, February 09, 2016 4:55 AM
> To: [email protected]
> Cc: Daryl McDaniel <[email protected]>; Jaben Carsey
> <[email protected]>
> Subject: [PATCH] rrecp has been allocated but is not freed on the error return
> path if the strdup fails. This is a minor memory leak that is easily fixed by
> free'ing rrecp on the error return.
> 
> From: Colin Ian King <[email protected]>
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Colin Ian King <[email protected]>
> ---
>  StdLib/BsdSocketLib/res_mkupdate.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/StdLib/BsdSocketLib/res_mkupdate.c
> b/StdLib/BsdSocketLib/res_mkupdate.c
> index d81d7d6..b1539be 100644
> --- a/StdLib/BsdSocketLib/res_mkupdate.c
> +++ b/StdLib/BsdSocketLib/res_mkupdate.c
> @@ -438,8 +438,12 @@ res_mkupdrec(int section, const char *dname,
>           u_int class, u_int type, u_long ttl) {
>      ns_updrec *rrecp = (ns_updrec *)calloc(1, sizeof(ns_updrec));
> 
> -    if (!rrecp || !(rrecp->r_dname = strdup(dname)))
> +    if (!rrecp)
>          return (NULL);
> +    if (!(rrecp->r_dname = strdup(dname))) {
> +        free(rrecp);
> +        return (NULL);
> +    }
>      rrecp->r_class = (u_int16_t)class;
>      rrecp->r_type = (u_int16_t)type;
>      rrecp->r_ttl = (u_int32_t)ttl;
> --
> 2.7.0

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to