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)

This commit is contained in:
Andreas Merkle
2022-03-02 14:25:59 +01:00
committed by GitHub
parent 7d4992a811
commit 4da1051266

View File

@ -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;
}
}