Update draft release notes for 1.5.4.5
[gitweb.git] / builtin-grep.c
index f1ff8dc556ce6caa1cafe77be41396dd9b7c9ee6..0d6cc7361f6e1a70e4d3d9e24913d60e8ceb9e58 100644 (file)
@@ -644,7 +644,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
                                die("'%s': %s", argv[1], strerror(errno));
                        while (fgets(buf, sizeof(buf), patterns)) {
                                int len = strlen(buf);
-                               if (buf[len-1] == '\n')
+                               if (len && buf[len-1] == '\n')
                                        buf[len-1] = 0;
                                /* ignore empty line like grep does */
                                if (!buf[0])