]> git.lizzy.rs Git - linenoise.git/blobdiff - linenoise.c
Add an assertion for fd_printf() buffer size
[linenoise.git] / linenoise.c
index aee34470d9316d317bd4afd15ca4e84c57246365..f6b9442f677517cdb4f2e0d4cb3a697cb9cf29f9 100644 (file)
 #include <stdlib.h>
 #include <stdarg.h>
 #include <stdio.h>
+#include <assert.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
@@ -290,6 +291,8 @@ static void fd_printf(int fd, const char *format, ...)
 
     va_start(args, format);
     n = vsnprintf(buf, sizeof(buf), format, args);
+    /* This will never happen because we are sure to use fd_printf() for short sequences */
+    assert(n < sizeof(buf));
     va_end(args);
     IGNORE_RC(write(fd, buf, n));
 }