gnunet-developers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [GNUnet-developers] [PATCH] Fix setup_service memory leak in util/se


From: LRN
Subject: Re: [GNUnet-developers] [PATCH] Fix setup_service memory leak in util/service.c
Date: Wed, 7 Jun 2017 10:10:55 +0300
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:55.0) Gecko/20100101 Thunderbird/55.0a1

On 6/7/2017 4:51 AM, jah wrote:
> ---
>  src/util/service.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/util/service.c b/src/util/service.c
> index f63737e56..d195452c9 100644
> --- a/src/util/service.c
> +++ b/src/util/service.c
> @@ -1287,11 +1287,11 @@ setup_service (struct GNUNET_SERVICE_Handle *sh)
>        {
>          GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
>                               "bind");
> -        GNUNET_free (addrs[i++]);
> +        GNUNET_free (addrs[i]);
>          GNUNET_free (slc);
>          continue;
>        }
> -      GNUNET_free (addrs[i++]);
> +      GNUNET_free (addrs[i]);
>        GNUNET_CONTAINER_DLL_insert (sh->slc_head,
>                                    sh->slc_tail,
>                                    slc);
> 

For that matter, it should be possible to GNUNET_free(addrs[i])
unconditionally, before the socket opening check (GCC probably optimizes like
that anyway, but why not help it?).

More worrying, to me, is the fact that addrs array is "struct sockaddr ***",
where each struct is malloced individually and put into an array that is also
malloced itself. Maximum possible sockaddr size is known, so why isn't it just
a "struct sockaddr **"?

-- 
O< ascii ribbon - stop html email! - www.asciiribbon.org

Attachment: 0x6759BA74.asc
Description: application/pgp-keys

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]