mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-31 08:25:38 +00:00
base: fix bug in String::valid()
String::valid() does not check whether _length is zero. Consequently, this leads to _buf[-1] being evaluated.
This commit is contained in:
parent
e6c7596af5
commit
2262eb8347
@ -479,7 +479,7 @@ namespace Genode {
|
||||
static constexpr size_t capacity() { return CAPACITY; }
|
||||
|
||||
bool valid() const {
|
||||
return (_length <= CAPACITY) && (_buf[_length - 1] == '\0'); }
|
||||
return (_length <= CAPACITY) && (_length != 0) && (_buf[_length - 1] == '\0'); }
|
||||
|
||||
char const *string() const { return valid() ? _buf : ""; }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user