[PATCH] Fix resource leak - sockaddr is not properly freed

Maxim Dounin mdounin at mdounin.ru
Sun Mar 6 01:58:16 UTC 2022


Hello!

On Thu, Mar 03, 2022 at 02:11:26AM +0100, Lubos Uhliarik wrote:

>  # HG changeset patch
> # User Lubos Uhliarik <luhliari at redhat.com>
> # Date 1646269812 -3600
> #      Thu Mar 03 02:10:12 2022 +0100
> # Node ID 317e1e4b0c7343c49e0e13fc59ac75a565521b67
> # Parent  a736a7a613ea6e182ff86fbadcb98bb0f8891c0b
> Fix resource leak - sockaddr is not properly freed
> 
> sockaddr variable is allocated by ngx_resolver_calloc function but then it
> is
> going out of scope leaking the storage it points to.
> 
> diff -r a736a7a613ea -r 317e1e4b0c73 src/core/ngx_resolver.c
> --- a/src/core/ngx_resolver.c   Tue Feb 08 17:35:27 2022 +0300
> +++ b/src/core/ngx_resolver.c   Thu Mar 03 02:10:12 2022 +0100
> @@ -4260,6 +4260,8 @@
>      }
>  #endif
> 
> +    ngx_resolver_free(r, sockaddr);
> +
>      return dst;
>  }

Could you please clarify why do you think there is a leak?  Note 
that sockaddr is referenced in the dst array, which is being 
returned.

-- 
Maxim Dounin
http://mdounin.ru/



More information about the nginx-devel mailing list