Commit e0cffe35 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

Fix a couple of bugs spotted by valgrind.

parent 2e0b5336
......@@ -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';
}
......
......@@ -1361,9 +1361,9 @@ INT WINAPI GetPrivateProfileSectionA( LPCSTR section, LPSTR buffer,
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;
......
......@@ -266,12 +266,12 @@ static void test_RtlGetFullPathName_U(void)
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);
}
......
......@@ -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);
}
......
......@@ -299,7 +299,7 @@ static const char *default_dbgstr_an( const char *str, int n )
}
}
*dst++ = '"';
if (*str)
if (n > 0)
{
*dst++ = '.';
*dst++ = '.';
......@@ -352,7 +352,7 @@ static const char *default_dbgstr_wn( const WCHAR *str, int n )
}
}
*dst++ = '"';
if (*str)
if (n > 0)
{
*dst++ = '.';
*dst++ = '.';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment