On Tue, Feb 14, 2017 at 04:48:16PM +0100, Christian Couder wrote: > @@ -791,11 +791,11 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) > head_oid.hash, NULL); > if (head_p) { > head_len = strlen(head_p); > - memcpy(head, head_p, head_len + 1); > + head_cpy = xstrdup(head_p); > } > else { > head_len = 0; > - head[0] = 0; > + head_cpy = xstrdup(""); > } This fixes the problem, but I think we can simplify it quite a bit by using resolve_refdup(). Here's the patch series I ended up with: [1/3]: show-branch: drop head_len variable [2/3]: show-branch: store resolved head in heap buffer [3/3]: show-branch: use skip_prefix to drop magic numbers builtin/show-branch.c | 39 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) -Peff