Skip to content

Commit 4da1051

Browse files
authored
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)
1 parent 7d4992a commit 4da1051

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: cores/esp32/esp32-hal-uart.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,12 @@ int log_printf(const char *format, ...)
421421
va_list copy;
422422
va_start(arg, format);
423423
va_copy(copy, arg);
424-
len = vsnprintf(NULL, 0, format, arg);
424+
len = vsnprintf(NULL, 0, format, copy);
425425
va_end(copy);
426426
if(len >= sizeof(loc_buf)){
427427
temp = (char*)malloc(len+1);
428428
if(temp == NULL) {
429+
va_end(arg);
429430
return 0;
430431
}
431432
}

0 commit comments

Comments
 (0)