[PATCH] Add a subject indicating that the commit message is empty

Lukas Fleischer cgit at cryptocrack.de
Thu Aug 11 04:36:47 CEST 2011


On Thu, Aug 11, 2011 at 03:57:32AM +0300, Nezmer wrote:
> > > > +		ret->subject = xmalloc(20);
> > > 
> > > xstrdup already allocates memory. No need to invoke malloc here (doing
> > > this will result in a memory leak).
> 
> Good to know.
> 
> > 
> > Oh, and you obviously also introduce a memory leak by overwriting the
> > pointer stored in "ret->subject" before without free'ing it.
> 
> I assumed strchr(p, '\n') would return NULL here. I see that my
> assumption was wrong now.

It does. Notice the else branch though.

> 
> > This should be implemented slightly differently.
> > The idea sounds good, though. I'll have a look at that.
> 
> Thanks.
> 
> Would declaring a const char* in cgit.h and pointing all empty subjects
> to it be a good choice?

No. If you do that, cgit will crash when trying to free the subject
string in cgit_free_commitinfo().




More information about the CGit mailing list