From 4da1051266c2d664846f9eb7bc0d8936cb4b0848 Mon Sep 17 00:00:00 2001 From: Andreas Merkle Date: Wed, 2 Mar 2022 14:25:59 +0100 Subject: [PATCH] Bugfix of the following problems: Invalid variable argument list used to retrieve length. If length is greater or equal than the available buffer, a memory leak will happen because va_end() is missing. (#6360) --- cores/esp32/esp32-hal-uart.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index adc5d8c2..4581334b 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -421,11 +421,12 @@ int log_printf(const char *format, ...) va_list copy; va_start(arg, format); va_copy(copy, arg); - len = vsnprintf(NULL, 0, format, arg); + len = vsnprintf(NULL, 0, format, copy); va_end(copy); if(len >= sizeof(loc_buf)){ temp = (char*)malloc(len+1); if(temp == NULL) { + va_end(arg); return 0; } }