From: Junio C Hamano <gitster@pobox.com>
To: Brandon Casey <casey@nrlssc.navy.mil>
Cc: Jim Meyering <meyering@redhat.com>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] * remote.c (valid_fetch_refspec): remove useless if-before-free test
Date: Wed, 20 Aug 2008 17:16:25 -0700 [thread overview]
Message-ID: <7vr68jmdd2.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <pI8EXbuWhkm4pM0AaaTAPQQYBeFSffOSzCiM4NfNHKomivEcfUfShA@cipher.nrlssc.navy.mil> (Brandon Casey's message of "Wed, 20 Aug 2008 18:38:44 -0500")
Brandon Casey <casey@nrlssc.navy.mil> writes:
> Maybe we should also begin the process of not leaking memory here...
>
> diff --git a/remote.c b/remote.c
> index 7f2897b..984ad1b 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -449,6 +449,20 @@ static int verify_refname(char *name, int is_glob)
> return result;
> }
>
> +void free_refspecs(struct refspec *refspec, int nr_refspec)
> +{
> + int i;
> +
> + if (!refspec)
> + return;
> +
> + for (i = 0; i < nr_refspec; i++) {
> + free(refspec[i].src);
> + free(refspec[i].dst);
> + }
> + free(refspec);
> +}
Are you sure all the codepaths that stuff refspec[].{src,dst} give
freeable pointer? E.g. if anybody splits a originally single string
"refs/heads/foo:refs/remotes/origin/foo" into two by replacing the colon
with NUL and pointing the halves, and/or such string came from argv[]
without strdup(), I'd imagine free() would not like you very much.
I didn't look, though.
next prev parent reply other threads:[~2008-08-21 0:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-19 18:46 [PATCH] * remote.c (valid_fetch_refspec): remove useless if-before-free test Jim Meyering
2008-08-20 19:40 ` Alex Riesen
2008-08-20 20:22 ` Jim Meyering
2008-08-20 23:38 ` Brandon Casey
2008-08-21 0:16 ` Junio C Hamano [this message]
2008-08-21 0:33 ` Brandon Casey
2008-08-21 2:42 ` Junio C Hamano
2008-08-22 0:16 ` [PATCH] remote.c: add a function for deleting a refspec array and use it (twice) Brandon Casey
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=7vr68jmdd2.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=casey@nrlssc.navy.mil \
--cc=git@vger.kernel.org \
--cc=meyering@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.