From 09cee35add8c8686a3982f3f31de283450b625eb Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 7 Jun 2015 14:49:18 +0200 Subject: Fix check in cmark_strbuf_vprintf Avoid potential overflow and allow for different bufsize types. --- src/buffer.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index db575ed..08192da 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -192,8 +192,7 @@ void cmark_strbuf_vprintf(cmark_strbuf *buf, const char *format, va_list ap) abort(); } - // TODO: Check for overflow. - if (len + 1 <= buf->asize - buf->size) { + if ((size_t)len < (size_t)(buf->asize - buf->size)) { buf->size += len; break; } -- cgit v1.2.3