summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorChristian Couder <christian.couder@gmail.com>2017-03-30 21:03:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-04-21 03:57:26 (GMT)
commitccef2bb5fa752fac9351cabc61c1362c85d620ee (patch)
tree95d13e2925bbfd51853785eda11193b72d83e95f /read-cache.c
parentb46013950aff31b6626af96ccbf2c48469e36c66 (diff)
downloadgit-ccef2bb5fa752fac9351cabc61c1362c85d620ee.zip
git-ccef2bb5fa752fac9351cabc61c1362c85d620ee.tar.gz
git-ccef2bb5fa752fac9351cabc61c1362c85d620ee.tar.bz2
read-cache: avoid using git_path() in freshen_shared_index()
When performing an interactive rebase in split-index mode, the commit message that one should rework when squashing commits can contain some garbage instead of the usual concatenation of both of the commit messages. The code uses git_path() to compute the shared index filename, and passes it to check_and_freshen_file() as its argument; there is no guarantee that the rotating pathname buffer passed as argument will stay valid during the life of this call. Make our own copy before calling the function and pass the copy as its argument to avoid this risky pattern. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/read-cache.c b/read-cache.c
index 8cf0673..0b166c2 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1690,9 +1690,10 @@ unmap:
*/
static void freshen_shared_index(char *base_sha1_hex, int warn)
{
- const char *shared_index = git_path("sharedindex.%s", base_sha1_hex);
+ char *shared_index = git_pathdup("sharedindex.%s", base_sha1_hex);
if (!check_and_freshen_file(shared_index, 1) && warn)
warning("could not freshen shared index '%s'", shared_index);
+ free(shared_index);
}
int read_index_from(struct index_state *istate, const char *path)