git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] fast-import: fix segfault in store_tree()

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 28, 2014, 23:16 UTC
Message-ID
<xmqqwq9s6w8z.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1409237674-74185-3-git-send-email-satori@yandex-team.ru>
Maxim Bublis <satori@yandex-team.ru> writes:
Show 27 quoted lines
> Branch tree is NULLified by filedelete command if we are trying
> to delete root tree. Add sanity check and use load_tree() in that case.
>
> Signed-off-by: Maxim Bublis <satori@yandex-team.ru>
> ---
>  fast-import.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/fast-import.c b/fast-import.c
> index d73f58c..b77f12c 100644
> --- a/fast-import.c
> +++ b/fast-import.c
> @@ -1419,7 +1419,7 @@ static void mktree(struct tree_content *t, int v, struct strbuf *b)
>  
>  static void store_tree(struct tree_entry *root)
>  {
> -	struct tree_content *t = root->tree;
> +	struct tree_content *t;
>  	unsigned int i, j, del;
>  	struct last_object lo = { STRBUF_INIT, 0, 0, /* no_swap */ 1 };
>  	struct object_entry *le = NULL;
> @@ -1427,6 +1427,10 @@ static void store_tree(struct tree_entry *root)
>  	if (!is_null_sha1(root->versions[1].sha1))
>  		return;
>  
> +	if (!root->tree)
> +		load_tree(root)
Missing ';'
Show 5 quoted lines
> +	t = root->tree;
> +
>  	for (i = 0; i < t->entry_count; i++) {
>  		if (t->entries[i]->tree)
>  			store_tree(t->entries[i]);
Previous: Maxim BublisNext: Maxim Bublis
Message 6 of 7 in “fast-import: fix segfault and tests”
  1. 0/2 fast-import: fix segfault and testsMaxim Bublis, Aug 28, 2014
  2. 1/2 t9300: test filedelete rootMaxim Bublis, Aug 28, 2014
  3. Junio C HamanoAug 28, 2014
  4. Maxim BublisAug 29, 2014
  5. 2/2 fast-import: fix segfault in store_tree()Maxim Bublis, Aug 28, 2014
  6. Junio C HamanoAug 28, 2014
  7. Maxim BublisAug 29, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.