grep: NUL terminate input from a file
[gitweb.git] / builtin-grep.c
index d79a6260a4b6f9a467356de117e100cd1a457b23..63dc31c45c309c7a2a67977e5631cb5334b32ecf 100644 (file)
@@ -207,6 +207,7 @@ static int grep_file(struct grep_opt *opt, const char *filename)
                return 0;
        }
        close(i);
+       data[sz] = 0;
        if (opt->relative && opt->prefix_length)
                filename = quote_path_relative(filename, -1, &buf, opt->prefix);
        i = grep_buffer(opt, filename, data, sz);