]> git.refcnt.org Git - colorize.git/commitdiff
Terminate buffer with single NUL
authorSteven Schubiger <stsc@refcnt.org>
Mon, 21 Mar 2016 15:48:09 +0000 (16:48 +0100)
committerSteven Schubiger <stsc@refcnt.org>
Mon, 21 Mar 2016 15:48:09 +0000 (16:48 +0100)
colorize.c

index eb2be2f5080eb9acfa3a58f52fd977d29efe671f..16094c6e673c3e51eb33629a226700df0dfc62ed 100644 (file)
@@ -745,10 +745,10 @@ read_print_stream (bool bold, const struct color **colors, const char *file, FIL
         size_t bytes_read;
         char *eol;
         const char *line;
-        memset (buf, '\0', BUF_SIZE + 1);
         bytes_read = fread (buf, 1, BUF_SIZE, stream);
         if (bytes_read != BUF_SIZE && ferror (stream))
           vfprintf_fail (formats[FMT_ERROR], BUF_SIZE, "read");
+        buf[bytes_read] = '\0';
         line = buf;
         while ((eol = strpbrk (line, "\n\r")))
           {