From e79661a924d29a37e9865e9aec6c04d47dfbcea1 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Mon, 22 Feb 2021 01:39:56 +1100 Subject: [PATCH] [client] app: fix `format-truncation` false positive This is fixed by using the `valloc_sprintf` function provided in common/stringutils.h as the functionallity is literally identical. --- client/src/app.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/client/src/app.c b/client/src/app.c index e98a32b5..79f640ce 100644 --- a/client/src/app.c +++ b/client/src/app.c @@ -28,6 +28,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include "kb.h" #include "common/debug.h" +#include "common/stringutils.h" #include #include @@ -448,14 +449,11 @@ void app_alert(LG_MsgAlert type, const char * fmt, ...) if (!g_state.lgr || !g_params.showAlerts) return; + char * buffer; + va_list args; va_start(args, fmt); - const int length = vsnprintf(NULL, 0, fmt, args); - va_end(args); - - char *buffer = malloc(length + 1); - va_start(args, fmt); - vsnprintf(buffer, length + 1, fmt, args); + valloc_sprintf(&buffer, fmt, args); va_end(args); g_state.lgr->on_alert(