Check max_len before dereferencing pointer in Cstring constructor

Fixes #4112
This commit is contained in:
Christian Helmuth 2021-05-05 15:02:30 +02:00
parent 66feb939e6
commit 718f44ae5b

View File

@ -552,7 +552,7 @@ class Genode::Cstring
* null once we reach 'max_len'.
*/
size_t res = 0;
for (; str && *str && res < max_len; str++, res++);
for (; res < max_len && str && *str; str++, res++);
return res;
}