From a647ceda23acfb5ec6e40e93d41b7e282256a296 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Tue, 6 Oct 2020 15:41:57 +0200 Subject: [PATCH] fix buffer underflow read --- client/src/ui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/ui.c b/client/src/ui.c index ecc0cb94e..26759cc4d 100644 --- a/client/src/ui.c +++ b/client/src/ui.c @@ -356,7 +356,7 @@ static void fPrintAndLog(FILE *stream, const char *fmt, ...) { va_start(argptr, fmt); vsnprintf(buffer, sizeof(buffer), fmt, argptr); va_end(argptr); - if (buffer[strlen(buffer) - 1] == NOLF[0]) { + if (strlen(buffer) > 0 && buffer[strlen(buffer) - 1] == NOLF[0]) { linefeed = false; buffer[strlen(buffer) - 1] = 0; }