Re: [PATCH v4 1/4] Avoid Coverity warning about unfree()d git_exec_path()
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jan 9, 2017, 07:49 UTC
- Message-ID
- <alpine.DEB.2.20.1701090848520.3469@virtualbox>
- In-Reply-To
- <xmqqy3ylyqhf.fsf@gitster.mtv.corp.google.com>
Hi,
On Sun, 8 Jan 2017, Junio C Hamano wrote:
Show 17 quoted lines
> How about explaining it like this then? > > (only the log message has been corrected; diff is from the original). > > commit c9bb5d101ca657fa466afa8c4368c43ea7b7aca8 > Author: Johannes Schindelin <johannes.schindelin@gmx.de> > Date: Mon Jan 2 17:22:33 2017 +0100 > > git_exec_path: avoid Coverity warning about unfree()d result > > Technically, it is correct that git_exec_path() returns a possibly > malloc()ed string returned from system_path(), and it is sometimes > not allocated. Cache the result in a static variable and make sure > that we call system_path() only once, which plugs a potential leak. > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > Signed-off-by: Junio C Hamano <gitster@pobox.com>
Sounds good to me.
Ciao, Dscho