Happy little incident #4

Mcu32

Well-known member
by convention, printTo() returns the number of characters written.

not here:

(may cause string corruption or wrong length later)

Solution:
Code:
size_t IPAddress::printTo(Print& p) const
{
    size_t n = 0;
    int i=0;
    while (1) {
        n += p.print(_address.bytes[i], DEC);
        if (++i >= 4) return n;
        n += p.write('.');
    }
}
use return n;
 
Last edited:
An other little issue (maybe):
IPAddress::fromString() accepts ("192.168.7.") or even ("...") - I'm not sure if this is wanted(?).
 
Back
Top