]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/rm.c
read-cache.c: fix memory leaks caused by removed cache entries
[thirdparty/git.git] / builtin / rm.c
index 3a0e0eaab7d1fd8a298bb2519776abede5c685e2..171f37c1cc5371c307ef16ce67fefc1c40fbc2c2 100644 (file)
@@ -311,7 +311,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
                if (!match_pathspec_depth(&pathspec, ce->name, ce_namelen(ce), 0, seen))
                        continue;
                ALLOC_GROW(list.entry, list.nr + 1, list.alloc);
-               list.entry[list.nr].name = ce->name;
+               list.entry[list.nr].name = xstrdup(ce->name);
                list.entry[list.nr].is_submodule = S_ISGITLINK(ce->ce_mode);
                if (list.entry[list.nr++].is_submodule &&
                    !is_staging_gitmodules_ok())