]> git.ipfire.org Git - thirdparty/git.git/commit
submodule--helper: do not borrow absolute_path() result for too long
authorJunio C Hamano <gitster@pobox.com>
Fri, 1 Apr 2016 19:23:16 +0000 (12:23 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 1 Apr 2016 21:04:23 +0000 (14:04 -0700)
commit1ea4d9b7c8008f5172e9995d87e2cf2d594a7ac7
treeef6ba1be1cff7ab12a0dacd84a412b7cad2ad0cb
parentf8eaa0ba98b3bd9cb9035eba184a2d9806d30b27
submodule--helper: do not borrow absolute_path() result for too long

absolute_path() is designed to allow its callers to take a brief
peek of the result (typically, to be fed to functions like
strbuf_add() and relative_path() as a parameter) without having to
worry about freeing it, but the other side of the coin of that
memory model is that the caller shouldn't rely too much on the
result living forever--there may be a helper function the caller
subsequently calls that makes its own call to absolute_path(),
invalidating the earlier result.

Use xstrdup() to make our own copy, and free(3) it when we are done.
While at it, remove an unnecessary sm_gitdir_rel variable that was
only used to as a parameter to call absolute_path() and never used
again.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/submodule--helper.c