Subject: Re: [PATCH 2/2] --pretty=format: on-demand format expansion

From: René Scharfe <[email-masked]>
Date: Sat, 10 Nov 2007 17:24:26 +0100

Johannes Schindelin schrieb:
> Hi,
> 
> On Sat, 10 Nov 2007, René Scharfe wrote:
> 
>> [...] have cooked up a different one on top of a cleaned up version of 
>> mine.  It plays the dirty trick of reading expansions of repeated 
>> placeholders from the strbuf..
> 
> ... which would not work (likely even segfault) if you work with the same 
> private data on different strbufs.
> 
> But I guess it will not matter much in practice.

Only a single strbuf is used, and the function that copies the data
around, strbuf_adddup(), operates on a single strbuf, only.  Copying
data between two strbufs using strbuf_add() etc. would be safe.

What one should *not* do is this:

	strbuf_add(sb, sb->buf + offset, length);

This leads to problems when the buffer is realloc()ated by strbuf_add().

What other things can go wrong?  A segfault would definitely matter..

Thanks,
René