Xml_node: do not consider '0' in decoded_content

Do not leave space for a terminating '0' at the end of the dst buffer in
decoded_content as the method does not write this '0'. The caller of the
method shall take care of it instead.

Issue #2644
This commit is contained in:
Martin Stein 2018-01-16 14:43:24 +01:00 committed by Norman Feske
parent 1936667a53
commit 84e476facb
1 changed files with 3 additions and 3 deletions

View File

@ -683,7 +683,7 @@ class Genode::Xml_node
char const *src = content_base();
size_t src_len = content_size();
for (; dst_len > 1 && src_len; result_len++) {
for (; dst_len && src_len; result_len++) {
Decoded_character const decoded_character(src, src_len);
@ -703,8 +703,8 @@ class Genode::Xml_node
STRING decoded_content() const
{
char buf[STRING::capacity() + 1];
size_t const len = decoded_content(buf, sizeof(buf));
buf[min(len, STRING::capacity())] = 0;
size_t const len = decoded_content(buf, sizeof(buf) - 1);
buf[min(len, sizeof(buf) - 1)] = 0;
return STRING(Cstring(buf));
}