vcs-svn: fix intermittent repo_tree corruption
Pointers to directory entries do not remain valid after a call to dent_insert. Noticed in the course of importing a small Subversion repository (~1000 revs); after setting up a dirent for a certain path as a placeholder, by luck dent_insert would trigger a realloc that shifted around addresses, resulting in an import with that file replaced by a directory. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Nieder committed
Dec 5, 2010 at 03:32 UTC
3c93983875af53b9f172d7f7a1022d0954cb5689
1 file changed
+2
-2
vcs-svn/repo_tree.c
+2
-2
@@ -131,7 +131,7 @@ static void repo_write_dirent(uint32_t *path, uint32_t mode,
131
if (dent == key) {
132
dent->mode = REPO_MODE_DIR;
133
dent->content_offset = 0;
134
- dent_insert(&dir->entries, dent);
134
+ dent = dent_insert(&dir->entries, dent);
135
}
136
137
if (dent_offset(dent) < dent_pool.committed) {
@@ -142,7 +142,7 @@ static void repo_write_dirent(uint32_t *path, uint32_t mode,
142
dent->name_offset = name;
143
dent->mode = REPO_MODE_DIR;
144
dent->content_offset = dir_o;
145
- dent_insert(&dir->entries, dent);
145
+ dent = dent_insert(&dir->entries, dent);
146
}
147
148
dir = repo_dir_from_dirent(dent);