From dc6653887c2494a1fbbc56c7544f55ea8fef4a93 Mon Sep 17 00:00:00 2001 From: Paul Vriens Date: Thu, 26 Jul 2007 16:15:44 +0200 Subject: [PATCH] advapi32/service: Fix buffersize calculations for GetServiceDisplayNameW. --- dlls/advapi32/service.c | 4 ++++ dlls/advapi32/tests/service.c | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dlls/advapi32/service.c b/dlls/advapi32/service.c index bee4847ecd..0c373134c7 100644 --- a/dlls/advapi32/service.c +++ b/dlls/advapi32/service.c @@ -2356,6 +2356,10 @@ BOOL WINAPI GetServiceDisplayNameW( SC_HANDLE hSCManager, LPCWSTR lpServiceName, SetLastError(ret); return FALSE; } + + /* Always return the correct needed size on success */ + *lpcchBuffer = (size / sizeof(WCHAR)) - 1; + return TRUE; } diff --git a/dlls/advapi32/tests/service.c b/dlls/advapi32/tests/service.c index 77fc85a492..8fc1af9222 100644 --- a/dlls/advapi32/tests/service.c +++ b/dlls/advapi32/tests/service.c @@ -527,12 +527,9 @@ static void test_get_displayname(void) GetLastError() == ERROR_IO_PENDING /* W2K */ || GetLastError() == 0xdeadbeef /* NT4, XP, Vista */, "Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError()); - todo_wine - { ok(displaysize == tempsizeW, "Expected the needed buffersize\n"); ok(lstrlenW(displaynameW) == displaysize, "Expected the buffer to be the length of the string\n") ; - } ok(tempsize / 2 == tempsizeW, "Expected the needed buffersize (in bytes) to be the same for the A and W call\n");