9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Steve Simon <steve@quintile.net>
To: 9front@9front.org
Subject: Re: [9front] lock: Fix some memory leaks
Date: Sat, 21 Jan 2023 07:55:02 +0000	[thread overview]
Message-ID: <D784F665-8A94-45E0-8192-6D6BDBC1D8CD@quintile.net> (raw)
In-Reply-To: <Y8svFsDWIl5YSy3u@quark.home.arpa>

sorry, but this patch looks very wrong.

free after return does nothing.
calling waitfor twice allocates data twice.

i would also consider what happens after the waitfor() call - i have not looked at the source but i have a suspicion that lock exits, so there is no point in freeing memory anyway.

-Steve

> On 21 Jan 2023, at 12:18 am, Josiah Frentsos <jfrent@tilde.team> wrote:
> 
> diff bb36ba0617b5aa8263ea9b5ece8c1a5249fedc86 uncommitted
> --- a/sys/src/cmd/lock.c
> +++ b/sys/src/cmd/lock.c
> @@ -35,6 +35,7 @@
>        }
>        if (w->pid == pid)
>            return w;
> +        free(w);
>    }
> }
> 
> @@ -141,7 +142,8 @@
>        error("wait");
> 
>    postnote(PNPROC, lckpid, "die");
> -    waitfor(lckpid);
> +    free(waitfor(lckpid));
> +
>    if(w->msg[0]){
>        p = utfrune(w->msg, ':');
>        if(p && p[1])

  reply	other threads:[~2023-01-21  7:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-21  0:17 Josiah Frentsos
2023-01-21  7:55 ` Steve Simon [this message]
2023-01-22  0:36   ` Dan Cross
2023-01-22  7:09     ` Benjamin Purcell
2023-01-22  8:11       ` Steve Simon
2023-01-22 20:46 ` cinap_lenrek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D784F665-8A94-45E0-8192-6D6BDBC1D8CD@quintile.net \
    --to=steve@quintile.net \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).