diff --git a/cores/esp8266/pgmspace.cpp b/cores/esp8266/pgmspace.cpp index ed81039f4..e705a32f6 100644 --- a/cores/esp8266/pgmspace.cpp +++ b/cores/esp8266/pgmspace.cpp @@ -147,6 +147,7 @@ void* memmem_P(const void* buf, size_t bufSize, PGM_VOID_P findP, size_t findPSi char* strncpy_P(char* dest, PGM_P src, size_t size) { + bool size_known = (size != SIZE_IRRELEVANT); const char* read = src; char* write = dest; char ch = '.'; @@ -156,6 +157,14 @@ char* strncpy_P(char* dest, PGM_P src, size_t size) { *write++ = ch; size--; } + if (size_known) + { + while (size > 0) + { + *write++ = 0; + size--; + } + } return dest; }