blame: reject empty ranges -L,+0 and -L,-0
[gitweb.git] / line-range.c
index 3942475c2fc8e48c7f0a2d7808f77a4f71a1cde6..69e8d6b6c02101b4243e1850aa52c377ccaa0a2b 100644 (file)
@@ -21,11 +21,13 @@ static const char *parse_loc(const char *spec, nth_line_fn_t nth_line,
         * for 20 lines, or "-L <something>,-5" for 5 lines ending at
         * <something>.
         */
-       if (1 < begin && (spec[0] == '+' || spec[0] == '-')) {
+       if (1 <= begin && (spec[0] == '+' || spec[0] == '-')) {
                num = strtol(spec + 1, &term, 10);
                if (term != spec + 1) {
                        if (!ret)
                                return term;
+                       if (num == 0)
+                               die("-L invalid empty range");
                        if (spec[0] == '-')
                                num = 0 - num;
                        if (0 < num)