Skip to content

Commit

Permalink
oappend() debug message when buffer is full
Browse files Browse the repository at this point in the history
oappend() silently discards strings when the buffer is full, leading to strange effects like half-working UI pages.

The new debug message will help developers to understand what could be wrong.
  • Loading branch information
softhack007 committed Aug 27, 2023
1 parent fc1dd2d commit bb45bee
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion wled00/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,14 @@ bool oappendi(int i)
bool oappend(const char* txt)
{
uint16_t len = strlen(txt);
if (olen + len >= SETTINGS_STACK_BUF_SIZE)
if (olen + len >= SETTINGS_STACK_BUF_SIZE) {
#ifdef WLED_DEBUG
DEBUG_PRINT(F("oappend() buffer overflow. Cannnot append "));
DEBUG_PRINT(len); DEBUG_PRINT(F(" bytes \t\""));
DEBUG_PRINT(txt); DEBUG_PRINTLN(F("\""));
#endif
return false; // buffer full
}
strcpy(obuf + olen, txt);
olen += len;
return true;
Expand Down

0 comments on commit bb45bee

Please sign in to comment.