Fix: UTF-8 characters may be stored on up to 4 bytes
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 30 Aug 2015 21:43:45 +0000 (17:43 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 23 Sep 2015 19:56:46 +0000 (15:56 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/config/config.c

index 35d9bb2543284811ced1a899a1a8644ff3fda5ff..950fec4d1010503be63720619bfb5ec073eaf1f0 100644 (file)
@@ -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;
This page took 0.027114 seconds and 4 git commands to generate.