Re: [PATCH 075/194] fetch, push: do not use submodule as alternate in has_commits check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 5, 2018 at 6:55 PM, Stefan Beller <sbeller@xxxxxxxxxx> wrote:
> Both fetch and push still use alternates to access submodules in some
> other code paths, but this is progress towards eliminating the alternates
> hack that conflates access to the_repository and other repositories.
>
> Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx>
> Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx>
> ---
> diff --git a/submodule.c b/submodule.c
> @@ -832,24 +833,43 @@ static int check_has_commit(const struct object_id *oid, void *data)
> +static int open_submodule(struct repository *out, const char *path)
> +{
> +       struct strbuf sb = STRBUF_INIT;
> +
> +       if (submodule_to_gitdir(&sb, path))
> +               return -1;

submodule_to_gitdir() makes no promise that it has not made
allocations to 'sb' when it returns -1, so this is potentially
leaking. Therefore, you should strbuf_release() here.

> +
> +       if (repo_init(out, sb.buf, NULL)) {
> +               strbuf_release(&sb);
> +               return -1;
> +       }

Or just combine these two error cases:

    if (submodule_to_gitdir(...) || repo_init(...)) {
        strbuf_release(...);
        return -1;
    }

> +       out->submodule_prefix = xstrdup(path);
> +
> +       strbuf_release(&sb);
> +       return 0;
> +}



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux