From 3460f64f579aad365a44632068464b85573d3f3c Mon Sep 17 00:00:00 2001 From: akallabeth Date: Sat, 14 Sep 2024 20:34:59 +0200 Subject: [PATCH] [client,common] fix possible NULL dereference --- client/common/cmdline.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/common/cmdline.c b/client/common/cmdline.c index b75f534e3..d50cff5b1 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -434,15 +434,16 @@ static size_t print_description(const char* text, size_t start_offset, size_t cu char* str = _strdup(text); char* cur = str; - do - { + while (cur != NULL) cur = print_token(cur, start_offset, ¤t, limit, " ", "\r\n"); - } while (cur != NULL); free(str); const int rc = printf("\n"); if (rc >= 0) + { + WINPR_ASSERT(SIZE_MAX - rc >= current); current += (size_t)rc; + } return current; }