From 063b563079f019d0aa2666bb73c9d93aeb2fcc97 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Sat, 8 Oct 2016 00:18:12 +0300 Subject: [PATCH] Print::printf should allocate it's buffer --- cores/esp32/Print.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cores/esp32/Print.cpp b/cores/esp32/Print.cpp index 035acf01..34584c50 100644 --- a/cores/esp32/Print.cpp +++ b/cores/esp32/Print.cpp @@ -46,14 +46,18 @@ size_t Print::write(const uint8_t *buffer, size_t size) size_t Print::printf(const char *format, ...) { + char * temp; va_list arg; va_start(arg, format); size_t len = vsnprintf(NULL, 0, format, arg); - char temp[len+1]; - uint8_t * stemp = (uint8_t*)temp; + temp = new char[len+1]; + if(temp == NULL) { + return 0; + } len = vsnprintf(temp, len+1, format, arg); - write(stemp, len); + write((uint8_t*)temp, len); va_end(arg); + delete[] temp; return len; } /*