Skip to content

Commit 5d61d8d

Browse files
committed
copy va_list in Print::printf
1 parent 658f81b commit 5d61d8d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cores/esp32/Print.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,12 @@ size_t Print::printf(const char *format, ...)
4949
char loc_buf[64];
5050
char * temp = loc_buf;
5151
va_list arg;
52+
va_list copy;
5253
va_start(arg, format);
54+
va_copy(copy, arg);
5355
size_t len = vsnprintf(NULL, 0, format, arg);
54-
if(len > 64){
56+
va_end(copy);
57+
if(len >= sizeof(loc_buf)){
5558
temp = new char[len+1];
5659
if(temp == NULL) {
5760
return 0;

0 commit comments

Comments
 (0)