Re: [RFH/PATCH] prefix_path(): disallow absolute paths
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jan 29, 2008, 02:59 UTC
- Message-ID
- <alpine.LSU.1.00.0801290255050.23907@racer.site>
- In-Reply-To
- <7v7ihts61v.fsf@gitster.siamese.dyndns.org>
Hi,
On Mon, 28 Jan 2008, Junio C Hamano wrote:
Show 12 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
> >> +const char *prefix_path(const char *prefix, int len, const char *path)
> >> +{
> >> + const char *orig = path;
> >> + char *sanitized = xmalloc(len + strlen(path) + 1);
> >
> > There _has_ to be a way to avoid malloc()ing things that will _never_
> > be free()d again with every second patch ;-)
>
> Huh? prefix_path() already allocates for rewritten pathspec entries;
> this is nothing new.Right. It is nothing new. Except that we now allocate for more paths than before.
At the same time as introducing a new feature (path normalisation), we could introduce another change, which would introduce a function cleanup_prefixed_pathspecs(), which would free all path that were malloc()ed.
Ciao, Dscho