Skip to content

Commit 063b563

Browse files
committed
Print::printf should allocate it's buffer
1 parent bb9ded7 commit 063b563

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Diff for: cores/esp32/Print.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,18 @@ size_t Print::write(const uint8_t *buffer, size_t size)
4646

4747
size_t Print::printf(const char *format, ...)
4848
{
49+
char * temp;
4950
va_list arg;
5051
va_start(arg, format);
5152
size_t len = vsnprintf(NULL, 0, format, arg);
52-
char temp[len+1];
53-
uint8_t * stemp = (uint8_t*)temp;
53+
temp = new char[len+1];
54+
if(temp == NULL) {
55+
return 0;
56+
}
5457
len = vsnprintf(temp, len+1, format, arg);
55-
write(stemp, len);
58+
write((uint8_t*)temp, len);
5659
va_end(arg);
60+
delete[] temp;
5761
return len;
5862
}
5963
/*

0 commit comments

Comments
 (0)