Merge branch 'cc/split-index-config'
authorJunio C Hamano <gitster@pobox.com>
Wed, 26 Apr 2017 06:39:09 +0000 (15:39 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 26 Apr 2017 06:39:09 +0000 (15:39 +0900)
The split-index code configuration code used an unsafe git_path()
function without copying its result out.

* cc/split-index-config:
read-cache: avoid using git_path() in freshen_shared_index()

read-cache.c
index d8c657d6a7faa717be8459cf88de83acc51ddde1..b3d0f3c30bfd7ee054d406afd8d8df29342105c2 100644 (file)
@@ -1824,9 +1824,10 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
  */
 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)