public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail•com>
Cc: git@vger•kernel.org, josharian@gmail•com
Subject: Re: [PATCH 2/2] config.c: handle lock file in error case in git_config_rename_...
Date: Tue, 20 Dec 2016 12:09:58 -0800	[thread overview]
Message-ID: <xmqqfulijrah.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20161220094836.4131-2-pclouds@gmail.com> ("Nguyễn Thái Ngọc Duy"'s message of "Tue, 20 Dec 2016 16:48:36 +0700")

Nguyễn Thái Ngọc Duy  <pclouds@gmail•com> writes:

> We could rely on atexit() to clean up everything, but let's be
> explicit when we can. And it's good anyway because the function is
> called the second time in the same process, we're in trouble.
>
> This function should not affect the successful case because after
> commit_lock_file() is called, rollback_lock_file() becomes no-op.

Not really.  At the point of the first "goto out" in this function,
lock is merely an uninitialized pointer.

>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail•com>
> ---


>  config.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/config.c b/config.c
> index 505e0d0..e02def4 100644
> --- a/config.c
> +++ b/config.c
> @@ -2483,6 +2483,7 @@ int git_config_rename_section_in_file(const char *config_filename,
>  		ret = error_errno("could not write config file %s",
>  				  config_filename);
>  out:
> +	rollback_lock_file(lock);
>  	free(filename_buf);
>  	return ret;
>  }

      reply	other threads:[~2016-12-20 20:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-16 18:41 Segfault in git_config_set_multivar_in_file_gently with direct_io in FUSE filesystem Josh Bleecher Snyder
2016-12-19  9:21 ` [PATCH] config.c: handle error case for fstat() calls Nguyễn Thái Ngọc Duy
2016-12-19 18:14   ` Junio C Hamano
2016-12-20  9:47     ` Duy Nguyen
2016-12-20  9:48       ` [PATCH 1/2] config.c: rename label unlock_and_out Nguyễn Thái Ngọc Duy
2016-12-20  9:48         ` [PATCH 2/2] config.c: handle lock file in error case in git_config_rename_ Nguyễn Thái Ngọc Duy
2016-12-20 20:09           ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqfulijrah.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=josharian@gmail$(echo .)com \
    --cc=pclouds@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox