Re: [PATCH] system_path: use a static buffer
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 16, 2011, 20:43 UTC
- Message-ID
- <7vipvi7q5g.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <1300293183-26354-1-git-send-email-cmn@elego.de>
Carlos Martín Nieto <cmn@elego.de> writes:
Show 8 quoted lines
> Make system_path behave like the other path functions by using a > static buffer, fixing a memory leak. > > Also make sure the prefix pointer is always initialized to either > PREFIX or NULL. > > Signed-off-by: Carlos Martín Nieto <cmn@elego.de> > ---
Have you made sure all the callers are Ok with this change?
If somebody called system_path(GIT_EXEC_PATH), saved the result in a variable without copying, and then called system_path(ETC_GITATTRIBUTES), his variable may now have a value unrelated to GIT_EXEC_PATH, and you would fix all such callers to save the value away with strdup().