From: Michael Stapelberg Date: Fri, 26 Mar 2010 02:04:54 +0000 (+0100) Subject: Bugfix: null-terminate buffer X-Git-Tag: 3.e~6^2~24 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=41b6631f684558afc95f8b4288f6736cd71a758b;p=i3%2Fi3 Bugfix: null-terminate buffer --- diff --git a/src/cfgparse.y b/src/cfgparse.y index e2b03412..2774f05c 100644 --- a/src/cfgparse.y +++ b/src/cfgparse.y @@ -70,7 +70,7 @@ void parse_file(const char *f) { if (fstat(fd, &stbuf) == -1) die("Could not fstat file: %s\n", strerror(errno)); - buf = smalloc(stbuf.st_size * sizeof(char)); + buf = scalloc((stbuf.st_size + 1) * sizeof(char)); while (read_bytes < stbuf.st_size) { if ((ret = read(fd, buf + read_bytes, (stbuf.st_size - read_bytes))) < 0) die("Could not read(): %s\n", strerror(errno));