File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -148,11 +148,14 @@ bool oappendi(int i)
148148bool oappend (const char * txt)
149149{
150150 uint16_t len = strlen (txt);
151- if (olen + len >= SETTINGS_STACK_BUF_SIZE) {
152- USER_PRINT (F (" oappend() error: buffer full. Increase SETTINGS_STACK_BUF_SIZE for " ));
153- USER_PRINTF (" %2u bytes \t\" " , len /* 1 + olen + len - SETTINGS_STACK_BUF_SIZE*/ );
154- USER_PRINT (txt);
155- USER_PRINTLN (F (" \" " ));
151+ if ((obuf == nullptr ) || (olen + len >= SETTINGS_STACK_BUF_SIZE)) { // sanity checks
152+ if (obuf == nullptr ) { USER_PRINTLN (F (" oappend() error: obuf == nullptr." ));
153+ } else {
154+ USER_PRINT (F (" oappend() error: buffer full. Increase SETTINGS_STACK_BUF_SIZE for " ));
155+ USER_PRINTF (" %2u bytes \t\" " , len /* 1 + olen + len - SETTINGS_STACK_BUF_SIZE*/ );
156+ USER_PRINT (txt);
157+ USER_PRINTLN (F (" \" " ));
158+ }
156159 return false ; // buffer full
157160 }
158161 strcpy (obuf + olen, txt);
You can’t perform that action at this time.
0 commit comments