Alexandre Julliard : msxml3: Always set output length in encoding conversion.

Alexandre Julliard julliard at winehq.org
Wed Oct 20 15:58:40 CDT 2021


Module: wine
Branch: master
Commit: 9a335d89d0cc9c8cca04d41a8cd43b09a9488a20
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=9a335d89d0cc9c8cca04d41a8cd43b09a9488a20

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Oct 20 11:31:58 2021 +0200

msxml3: Always set output length in encoding conversion.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msxml3/main.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/dlls/msxml3/main.c b/dlls/msxml3/main.c
index 25400b698ca..e9a43ab64b2 100644
--- a/dlls/msxml3/main.c
+++ b/dlls/msxml3/main.c
@@ -233,9 +233,9 @@ static void init_libxslt(void)
 static int to_utf8(int cp, unsigned char *out, int *outlen, const unsigned char *in, int *inlen)
 {
     WCHAR *tmp;
-    int len;
+    int len = 0;
 
-    if (!in || !inlen) return 0;
+    if (!in || !inlen) goto done;
 
     len = MultiByteToWideChar(cp, 0, (const char *)in, *inlen, NULL, 0);
     tmp = heap_alloc(len * sizeof(WCHAR));
@@ -245,7 +245,7 @@ static int to_utf8(int cp, unsigned char *out, int *outlen, const unsigned char
     len = WideCharToMultiByte(CP_UTF8, 0, tmp, len, (char *)out, *outlen, NULL, NULL);
     heap_free(tmp);
     if (!len) return -1;
-
+done:
     *outlen = len;
     return len;
 }
@@ -253,9 +253,9 @@ static int to_utf8(int cp, unsigned char *out, int *outlen, const unsigned char
 static int from_utf8(int cp, unsigned char *out, int *outlen, const unsigned char *in, int *inlen)
 {
     WCHAR *tmp;
-    int len;
+    int len = 0;
 
-    if (!in || !inlen) return 0;
+    if (!in || !inlen) goto done;
 
     len = MultiByteToWideChar(CP_UTF8, 0, (const char *)in, *inlen, NULL, 0);
     tmp = heap_alloc(len * sizeof(WCHAR));
@@ -265,7 +265,7 @@ static int from_utf8(int cp, unsigned char *out, int *outlen, const unsigned cha
     len = WideCharToMultiByte(cp, 0, tmp, len, (char *)out, *outlen, NULL, NULL);
     heap_free(tmp);
     if (!len) return -1;
-
+done:
     *outlen = len;
     return len;
 }




More information about the wine-cvs mailing list