From 6bb1ef024dd8d3872e18c388a8d448fe2822fba8 Mon Sep 17 00:00:00 2001 From: BlueAndi Date: Mon, 28 Feb 2022 22:00:27 +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. --- 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 157c3640830..0b507f833cf 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -481,11 +481,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; } }