From 5d61d8ddd004e83fec3d5cabca46c1990fee7b13 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Tue, 11 Oct 2016 11:42:47 +0300 Subject: [PATCH] copy va_list in Print::printf --- cores/esp32/Print.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cores/esp32/Print.cpp b/cores/esp32/Print.cpp index d758478b..5afa9ded 100644 --- a/cores/esp32/Print.cpp +++ b/cores/esp32/Print.cpp @@ -49,9 +49,12 @@ size_t Print::printf(const char *format, ...) char loc_buf[64]; char * temp = loc_buf; va_list arg; + va_list copy; va_start(arg, format); + va_copy(copy, arg); size_t len = vsnprintf(NULL, 0, format, arg); - if(len > 64){ + va_end(copy); + if(len >= sizeof(loc_buf)){ temp = new char[len+1]; if(temp == NULL) { return 0;