Merge branch 'maint-1.6.0' into maint
authorJunio C Hamano <gitster@pobox.com>
Tue, 27 Jan 2009 23:23:46 +0000 (15:23 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 27 Jan 2009 23:23:46 +0000 (15:23 -0800)
* maint-1.6.0:
test-path-utils: Fix off by one, found by valgrind
get_sha1_basic(): fix invalid memory access, found by valgrind

1  2 
sha1_name.c
diff --combined sha1_name.c
index 159c2ab84fa2cdde0e540024a1ca22e0bbb43af8,c4fdaded01192f4ddb3c8956dd5d1f7b83606817..722fc35a6d98e1c260c6e14738ad3b2d41d924aa
@@@ -309,7 -309,7 +309,7 @@@ static int get_sha1_basic(const char *s
  
        /* basic@{time or number} format to query ref-log */
        reflog_len = at = 0;
-       if (str[len-1] == '}') {
+       if (len && str[len-1] == '}') {
                for (at = 0; at < len - 1; at++) {
                        if (str[at] == '@' && str[at+1] == '{') {
                                reflog_len = (len-1) - (at+2);
                        else
                                nth = -1;
                }
 -              if (0 <= nth)
 +              if (100000000 <= nth) {
 +                      at_time = nth;
 +                      nth = -1;
 +              } else if (0 <= nth)
                        at_time = 0;
                else {
                        char *tmp = xstrndup(str + at + 2, reflog_len);