From: Jérémie Galarneau Date: Sun, 30 Aug 2015 21:43:45 +0000 (-0400) Subject: Fix: UTF-8 characters may be stored on up to 4 bytes X-Git-Tag: v2.6.1~66 X-Git-Url: https://git.liburcu.org/?a=commitdiff_plain;h=e0b9045bcb72b60f1776d7a363ffaec6511a2e9a;p=lttng-tools.git Fix: UTF-8 characters may be stored on up to 4 bytes Signed-off-by: Jérémie Galarneau --- diff --git a/src/common/config/config.c b/src/common/config/config.c index 35d9bb254..950fec4d1 100644 --- a/src/common/config/config.c +++ b/src/common/config/config.c @@ -330,11 +330,10 @@ static xmlChar *encode_string(const char *in_str) in_len = strlen(in_str); /* - * Add 1 byte for the NULL terminted character. The factor 2 here is - * because UTF-8 can be on two bytes so this fits the worst case for each - * bytes. + * Add 1 byte for the NULL terminted character. The factor 4 here is + * used because UTF-8 characters can take up to 4 bytes. */ - out_len = (in_len * 2) + 1; + out_len = (in_len * 4) + 1; out_str = xmlMalloc(out_len); if (!out_str) { goto end;