Fix for the empty string (REG_SZ) problem
authorMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>
Tue, 9 Sep 2008 15:44:41 +0000 (17:44 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Tue, 21 Oct 2008 12:40:40 +0000 (14:40 +0200)
I enhanced the "utf8_push" function, who finally accepts now also the char sequence "" with length 1 as valid UTF8 string.

source4/lib/charset/iconv.c

index d4f930b4622dc8893d4f58acd6a743374d5caf9d..9b15cfb3cca7d505b863e1f976fb0a14efba1521 100644 (file)
@@ -600,6 +600,14 @@ static size_t utf8_push(void *cd, const char **inbuf, size_t *inbytesleft,
        uint8_t *c = (uint8_t *)*outbuf;
        const uint8_t *uc = (const uint8_t *)*inbuf;
 
+       /* Special case: Windows (e.g. "regedit") also expects an empty buffer
+          with length 1 as a valid empty UTF8 string */
+       if (in_left == 1 && uc[0] == 0 && out_left >= 1) {
+               c[0] = uc[0];
+               in_left  -= 1;
+               out_left -= 1;
+       }
+
        while (in_left >= 2 && out_left >= 1) {
                unsigned int codepoint;