summaryrefslogtreecommitdiff
path: root/src/buf.c
diff options
context:
space:
mode:
authorrlar <rlar>2016-03-01 17:59:09 +0100
committerWill Estes <westes575@gmail.com>2016-03-08 15:20:45 -0500
commit00bc43fa045008aa306ef07d4f5d018d91f233ed (patch)
treeef49347e8314f4d2193d32dc76a67ef9bd81d02b /src/buf.c
parentc7b3db795737dc396a3106b1957207ab56f786b7 (diff)
cast and fix usage of log10(), ceil to prevent buffer overflow
Diffstat (limited to 'src/buf.c')
-rw-r--r--src/buf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/buf.c b/src/buf.c
index c03b85f..185cbd3 100644
--- a/src/buf.c
+++ b/src/buf.c
@@ -100,7 +100,7 @@ struct Buf *buf_linedir (struct Buf *buf, const char* filename, int lineno)
tsz = strlen("#line \"\"\n") + /* constant parts */
2 * strlen (filename) + /* filename with possibly all backslashes escaped */
- (int) (1 + log10 (abs (lineno))) + /* line number */
+ (size_t) (1 + ceil (log10 (abs (lineno)))) + /* line number */
1; /* NUL */
t = malloc(tsz);
if (!t)