forked from espressif/arduino-esp32
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:
@ -421,11 +421,12 @@ int log_printf(const char *format, ...)
|
|||||||
va_list copy;
|
va_list copy;
|
||||||
va_start(arg, format);
|
va_start(arg, format);
|
||||||
va_copy(copy, arg);
|
va_copy(copy, arg);
|
||||||
len = vsnprintf(NULL, 0, format, arg);
|
len = vsnprintf(NULL, 0, format, copy);
|
||||||
va_end(copy);
|
va_end(copy);
|
||||||
if(len >= sizeof(loc_buf)){
|
if(len >= sizeof(loc_buf)){
|
||||||
temp = (char*)malloc(len+1);
|
temp = (char*)malloc(len+1);
|
||||||
if(temp == NULL) {
|
if(temp == NULL) {
|
||||||
|
va_end(arg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user