copy va_list in Print::printf

This commit is contained in:
me-no-dev 2016-10-11 11:42:47 +03:00
parent 658f81b792
commit 5d61d8ddd0

View File

@ -49,9 +49,12 @@ size_t Print::printf(const char *format, ...)
char loc_buf[64]; char loc_buf[64];
char * temp = loc_buf; char * temp = loc_buf;
va_list arg; va_list arg;
va_list copy;
va_start(arg, format); va_start(arg, format);
va_copy(copy, arg);
size_t len = vsnprintf(NULL, 0, format, 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]; temp = new char[len+1];
if(temp == NULL) { if(temp == NULL) {
return 0; return 0;