]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/commit.c
determine_author_info(): copy getenv output
authorJeff King <peff@peff.net>
Wed, 27 Aug 2014 07:57:56 +0000 (03:57 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 29 Aug 2014 17:33:28 +0000 (10:33 -0700)
commitf4ef51739343f80c7cb0467244925b3725d65730
tree8e97ad99b286cf2e68150ca48df5d37a526e44b2
parentf0f9662ae9d1c7f58a95397d1c6d5f31760b14be
determine_author_info(): copy getenv output

When figuring out the author name for a commit, we may end
up either pointing to const storage from getenv("GIT_AUTHOR_*"),
or to newly allocated storage based on an existing commit or
the --author option.

Using const pointers to getenv's return has two problems:

  1. It is not guaranteed that the return value from getenv
     remains valid across multiple calls.

  2. We do not know whether to free the values at the end,
     so we just leak them.

We can solve both by duplicating the string returned by
getenv().

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/commit.c