From: Wang Hui Date: Tue, 06 Sep 2011 10:24:02 GMT Subject: [PATCH v2 2/5] sha1_file: remove a buggy value setting Message-ID: <1315304645-12009-3-git-send-email-Hui.Wang@windriver.com> In-Reply-To: <1315304645-12009-2-git-send-email-Hui.Wang@windriver.com> From: Hui Wang The ent->base[] is a character array, it has pfxlen characters from position 0 to (pfxlen-1) to contain an alt object dir name, the position pfxlen should be the string terminating character '\0' and is deliberately set to '\0' at the previous code line. The position (pfxlen+1) is given to ent->name. >From above analysis, there is no reason to set ent->base[pfxlen] to '/' at the end of this function, first it doesn't make sense to append a '/' at the end of a dir name, second if you are not lucky that the ent->base[pfxlen+1] is not 0, you will get a wrong alt object dir name. Signed-off-by: Hui Wang --- sha1_file.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diff --git a/sha1_file.c b/sha1_file.c index d12a675..5940d84 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -304,8 +304,6 @@ static int link_alt_odb_entry(const char * entry, int len, const char * relative /* recursively add alternates */ read_info_alternates(ent->base, depth + 1); - ent->base[pfxlen] = '/'; - return 0; } -- 1.6.3.1