Merge branch 'maint-1.6.5' into maint
authorJunio C Hamano <gitster@pobox.com>
Tue, 9 Feb 2010 05:53:54 +0000 (21:53 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 9 Feb 2010 05:53:54 +0000 (21:53 -0800)
* maint-1.6.5:
blame: prevent a segv when -L given start > EOF

builtin-blame.c
t/t8003-blame.sh
index 6408ec8ee6805fc42eb5e5dc52be6463d62128bf..10f7eacf6e881cdb54a6b4a4c0aafc5f9751e5a9 100644 (file)
@@ -2433,7 +2433,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
        if (top < 1)
                top = lno;
        bottom--;
-       if (lno < top)
+       if (lno < top || lno < bottom)
                die("file %s has only %lu lines", path, lno);
 
        ent = xcalloc(1, sizeof(*ent));
index ad834f200ac0d6ecf532374311d896557a9b941d..4a8db74f7e09a143e73d647479ef62af91547865 100755 (executable)
@@ -157,4 +157,12 @@ EOF
   git --no-pager blame $COMMIT -- uno >/dev/null
 '
 
+test_expect_success 'blame -L with invalid start' '
+       test_must_fail git blame -L5 tres 2>&1 | grep "has only 2 lines"
+'
+
+test_expect_success 'blame -L with invalid end' '
+       git blame -L1,5 tres 2>&1 | grep "has only 2 lines"
+'
+
 test_done