base: fix bug in String::valid()

String::valid() does not check whether _length is zero.
Consequently, this leads to _buf[-1] being evaluated.