From 84e476facba46d125710c6afc23a4c3c4c3952c1 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Tue, 16 Jan 2018 14:43:24 +0100 Subject: [PATCH] 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 --- repos/base/include/util/xml_node.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/repos/base/include/util/xml_node.h b/repos/base/include/util/xml_node.h index 75f2fd745..7194ad24b 100644 --- a/repos/base/include/util/xml_node.h +++ b/repos/base/include/util/xml_node.h @@ -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)); }