Merge branch 'rs/fix-alt-odb-path-comparison'
authorJunio C Hamano <gitster@pobox.com>
Thu, 10 Jul 2014 18:27:52 +0000 (11:27 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 10 Jul 2014 18:27:52 +0000 (11:27 -0700)
* rs/fix-alt-odb-path-comparison:
sha1_file: avoid overrunning alternate object base string

sha1_file.c
index 34d527f6708fe242f75b7fa0fa98e36a5c96a3be..a38854ce553c1e59294d5542a37a5404ccd66dc5 100644 (file)
@@ -315,7 +315,8 @@ static int link_alt_odb_entry(const char *entry, const char *relative_base, int
         * thing twice, or object directory itself.
         */
        for (alt = alt_odb_list; alt; alt = alt->next) {
-               if (!memcmp(ent->base, alt->base, pfxlen)) {
+               if (pfxlen == alt->name - alt->base - 1 &&
+                   !memcmp(ent->base, alt->base, pfxlen)) {
                        free(ent);
                        return -1;
                }