Eric Pouech : Fix a couple of bugs spotted by valgrind.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Jan 27 09:19:18 CST 2006
Module: wine
Branch: refs/heads/master
Commit: e0cffe355ff3d99fa4b82c9f7c55b71d5bf09618
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=e0cffe355ff3d99fa4b82c9f7c55b71d5bf09618
Author: Eric Pouech <eric.pouech at wanadoo.fr>
Date: Fri Jan 27 16:18:05 2006 +0100
Fix a couple of bugs spotted by valgrind.
---
dlls/kernel/lcformat.c | 2 +-
dlls/kernel/profile.c | 4 ++--
dlls/ntdll/tests/path.c | 4 ++--
dlls/ntdll/tests/reg.c | 2 --
libs/wine/debug.c | 4 ++--
5 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/dlls/kernel/lcformat.c b/dlls/kernel/lcformat.c
index 0f6e1e8..9f36cef 100644
--- a/dlls/kernel/lcformat.c
+++ b/dlls/kernel/lcformat.c
@@ -708,7 +708,7 @@ GetDateTimeFormatA_InvalidParameter:
if (lpStr)
{
if (szOut[0])
- WideCharToMultiByte(cp, 0, szOut, -1, lpStr, cchOut, 0, 0);
+ WideCharToMultiByte(cp, 0, szOut, iRet ? -1 : cchOut, lpStr, cchOut, 0, 0);
else if (cchOut && iRet)
*lpStr = '\0';
}
diff --git a/dlls/kernel/profile.c b/dlls/kernel/profile.c
index 523357d..355b547 100644
--- a/dlls/kernel/profile.c
+++ b/dlls/kernel/profile.c
@@ -1361,9 +1361,9 @@ INT WINAPI GetPrivateProfileSectionA( LP
retW = GetPrivateProfileSectionW(sectionW.Buffer, bufferW, len, filenameW.Buffer);
if (len > 2)
{
- ret = WideCharToMultiByte(CP_ACP, 0, bufferW, retW + 2, buffer, len, NULL, NULL);
+ ret = WideCharToMultiByte(CP_ACP, 0, bufferW, retW + 1, buffer, len, NULL, NULL);
if (ret > 2)
- ret -= 2;
+ ret -= 1;
else
{
ret = 0;
diff --git a/dlls/ntdll/tests/path.c b/dlls/ntdll/tests/path.c
index d8ba775..7b2fb73 100644
--- a/dlls/ntdll/tests/path.c
+++ b/dlls/ntdll/tests/path.c
@@ -266,12 +266,12 @@ static void test_RtlGetFullPathName_U(vo
pRtlMultiByteToUnicodeN(pathbufW , sizeof(pathbufW), NULL, test->path, strlen(test->path)+1 );
ret = pRtlGetFullPathName_U( pathbufW,MAX_PATH, rbufferW, &file_part);
ok( ret == len, "Wrong result %ld/%d for \"%s\"\n", ret, len, test->path );
- ok(pRtlUnicodeToMultiByteN(rbufferA,MAX_PATH,&reslen,rbufferW,MAX_PATH) == STATUS_SUCCESS,
+ ok(pRtlUnicodeToMultiByteN(rbufferA,MAX_PATH,&reslen,rbufferW,(lstrlenW(rbufferW) + 1) * sizeof(WCHAR)) == STATUS_SUCCESS,
"RtlUnicodeToMultiByteN failed\n");
ok(lstrcmpiA(rbufferA,test->rname) == 0, "Got \"%s\" expected \"%s\"\n",rbufferA,test->rname);
if (file_part)
{
- ok(pRtlUnicodeToMultiByteN(rfileA,MAX_PATH,&reslen,file_part,MAX_PATH) == STATUS_SUCCESS,
+ ok(pRtlUnicodeToMultiByteN(rfileA,MAX_PATH,&reslen,file_part,(lstrlenW(file_part) + 1) * sizeof(WCHAR)) == STATUS_SUCCESS,
"RtlUnicodeToMultiByteN failed\n");
ok(test->rfile && !lstrcmpiA(rfileA,test->rfile), "Got \"%s\" expected \"%s\"\n",rfileA,test->rfile);
}
diff --git a/dlls/ntdll/tests/reg.c b/dlls/ntdll/tests/reg.c
index c94748a..b6a0d92 100644
--- a/dlls/ntdll/tests/reg.c
+++ b/dlls/ntdll/tests/reg.c
@@ -294,7 +294,6 @@ static void test_NtCreateKey(void)
{
/*Create WineTest*/
OBJECT_ATTRIBUTES attr;
- UNICODE_STRING ValName;
HKEY key;
ACCESS_MASK am = GENERIC_ALL;
NTSTATUS status;
@@ -303,7 +302,6 @@ static void test_NtCreateKey(void)
status = pNtCreateKey(&key, am, &attr, 0, 0, 0, 0);
ok(status == STATUS_SUCCESS, "NtCreateKey Failed: 0x%08lx\n", status);
- pRtlFreeUnicodeString(&ValName);
pNtClose(&key);
}
diff --git a/libs/wine/debug.c b/libs/wine/debug.c
index f6ee71b..a17248b 100644
--- a/libs/wine/debug.c
+++ b/libs/wine/debug.c
@@ -299,7 +299,7 @@ static const char *default_dbgstr_an( co
}
}
*dst++ = '"';
- if (*str)
+ if (n > 0)
{
*dst++ = '.';
*dst++ = '.';
@@ -352,7 +352,7 @@ static const char *default_dbgstr_wn( co
}
}
*dst++ = '"';
- if (*str)
+ if (n > 0)
{
*dst++ = '.';
*dst++ = '.';
More information about the wine-cvs
mailing list