From a1bb58017bded3a64eabd629fd2e6374bfa72095 Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Mon, 2 May 2016 12:04:14 +0100 Subject: [PATCH] Fix off-by-one bug in log functions --- common/log.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/log.c b/common/log.c index 6d958db2..c68f0516 100644 --- a/common/log.c +++ b/common/log.c @@ -68,7 +68,7 @@ void _sway_log(log_importance_t verbosity, const char* format, ...) { #endif if (verbosity <= v) { unsigned int c = verbosity; - if (c > sizeof(verbosity_colors) / sizeof(char *)) { + if (c > sizeof(verbosity_colors) / sizeof(char *) - 1) { c = sizeof(verbosity_colors) / sizeof(char *) - 1; } @@ -96,7 +96,7 @@ void _sway_log(log_importance_t verbosity, const char* format, ...) { void sway_log_errno(log_importance_t verbosity, char* format, ...) { if (verbosity <= v) { unsigned int c = verbosity; - if (c > sizeof(verbosity_colors) / sizeof(char *)) { + if (c > sizeof(verbosity_colors) / sizeof(char *) - 1) { c = sizeof(verbosity_colors) / sizeof(char *) - 1; }