[PATCH] wmc: duplicate wine_cp_wcstombs check here too (Coverity)

Marcus Meissner marcus at jet.franken.de
Sat Jul 18 15:23:45 CDT 2009


Hi,

Last commit has added utf8 support for most of these, but
missed that one call.

Ciao, Marcus
---
 tools/wmc/write.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/wmc/write.c b/tools/wmc/write.c
index 22858b8..7f9784f 100644
--- a/tools/wmc/write.c
+++ b/tools/wmc/write.c
@@ -396,8 +396,13 @@ static char *make_string(WCHAR *uc, int len, int codepage)
                 else
                     mlen = wine_utf8_wcstombs(0, uc, unistrlen(uc)+1, NULL, 0);
 		cc = tmp = xmalloc(mlen);
-		if((i = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, tmp, mlen, NULL, NULL)) < 0)
-			internal_error(__FILE__, __LINE__, "Buffer overflow? code %d\n", i);
+                if (cpdef) {
+                    if((i = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, tmp, mlen, NULL, NULL)) < 0)
+                        internal_error(__FILE__, __LINE__, "Buffer overflow? code %d\n", i);
+                } else {
+                    if((i = wine_utf8_wcstombs(0, uc, unistrlen(uc)+1, tmp, mlen)) < 0)
+                        internal_error(__FILE__, __LINE__, "Buffer overflow? code %d\n", i);
+                }
 		*cptr++ = ' ';
 		*cptr++ = '"';
 		for(i = b = 0; i < len; i++, cc++)
-- 
1.5.6



More information about the wine-patches mailing list