summaryrefslogtreecommitdiff
path: root/builtin/receive-pack.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2019-03-07 09:59:57 +0900
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-03-07 09:59:57 +0900
commit4751a1673c7d4aeb1b6462f89fa7d86c05898d05 (patch)
tree930ba74ef43d0c96462056e00dc80e1ec5f11eff /builtin/receive-pack.c
parentMerge branch 'dl/doc-submodule-wo-subcommand' (diff)
parentreceive-pack: fix use-after-free bug (diff)
downloadtgif-4751a1673c7d4aeb1b6462f89fa7d86c05898d05.tar.xz
Merge branch 'ab/receive-pack-use-after-free-fix'
Memfix. * ab/receive-pack-use-after-free-fix: receive-pack: fix use-after-free bug
Diffstat (limited to 'builtin/receive-pack.c')
-rw-r--r--builtin/receive-pack.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 8bc714a5fc..29f165d8bd 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1202,17 +1202,12 @@ static void run_update_post_hook(struct command *commands)
}
}
-static void check_aliased_update(struct command *cmd, struct string_list *list)
+static void check_aliased_update_internal(struct command *cmd,
+ struct string_list *list,
+ const char *dst_name, int flag)
{
- struct strbuf buf = STRBUF_INIT;
- const char *dst_name;
struct string_list_item *item;
struct command *dst_cmd;
- int flag;
-
- strbuf_addf(&buf, "%s%s", get_git_namespace(), cmd->ref_name);
- dst_name = resolve_ref_unsafe(buf.buf, 0, NULL, &flag);
- strbuf_release(&buf);
if (!(flag & REF_ISSYMREF))
return;
@@ -1251,6 +1246,18 @@ static void check_aliased_update(struct command *cmd, struct string_list *list)
"inconsistent aliased update";
}
+static void check_aliased_update(struct command *cmd, struct string_list *list)
+{
+ struct strbuf buf = STRBUF_INIT;
+ const char *dst_name;
+ int flag;
+
+ strbuf_addf(&buf, "%s%s", get_git_namespace(), cmd->ref_name);
+ dst_name = resolve_ref_unsafe(buf.buf, 0, NULL, &flag);
+ check_aliased_update_internal(cmd, list, dst_name, flag);
+ strbuf_release(&buf);
+}
+
static void check_aliased_updates(struct command *commands)
{
struct command *cmd;