Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msi/msiquery.c | 26 ++++++-------------------- dlls/msi/tests/db.c | 4 ++-- 2 files changed, 8 insertions(+), 22 deletions(-)
diff --git a/dlls/msi/msiquery.c b/dlls/msi/msiquery.c index 862805fdbd..3c22a2159f 100644 --- a/dlls/msi/msiquery.c +++ b/dlls/msi/msiquery.c @@ -772,7 +772,6 @@ MSIDBERROR WINAPI MsiViewGetErrorW( MSIHANDLE handle, LPWSTR buffer, LPDWORD buf MSIQUERY *query; const WCHAR *column; MSIDBERROR r; - DWORD len;
TRACE("%u %p %p\n", handle, buffer, buflen);
@@ -786,15 +785,9 @@ MSIDBERROR WINAPI MsiViewGetErrorW( MSIHANDLE handle, LPWSTR buffer, LPDWORD buf if ((r = query->view->error)) column = query->view->error_column; else column = szEmpty;
- len = strlenW( column ); - if (buffer) - { - if (*buflen > len) - strcpyW( buffer, column ); - else - r = MSIDBERROR_MOREDATA; - } - *buflen = len; + if (msi_strncpyW(column, -1, buffer, buflen) == ERROR_MORE_DATA) + r = MSIDBERROR_MOREDATA; + msiobj_release( &query->hdr ); return r; } @@ -804,7 +797,6 @@ MSIDBERROR WINAPI MsiViewGetErrorA( MSIHANDLE handle, LPSTR buffer, LPDWORD bufl MSIQUERY *query; const WCHAR *column; MSIDBERROR r; - DWORD len;
TRACE("%u %p %p\n", handle, buffer, buflen);
@@ -818,15 +810,9 @@ MSIDBERROR WINAPI MsiViewGetErrorA( MSIHANDLE handle, LPSTR buffer, LPDWORD bufl if ((r = query->view->error)) column = query->view->error_column; else column = szEmpty;
- len = WideCharToMultiByte( CP_ACP, 0, column, -1, NULL, 0, NULL, NULL ); - if (buffer) - { - if (*buflen >= len) - WideCharToMultiByte( CP_ACP, 0, column, -1, buffer, *buflen, NULL, NULL ); - else - r = MSIDBERROR_MOREDATA; - } - *buflen = len - 1; + if (msi_strncpyWtoA(column, -1, buffer, buflen, FALSE) == ERROR_MORE_DATA) + r = MSIDBERROR_MOREDATA; + msiobj_release( &query->hdr ); return r; } diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c index 16b20e530b..181301e1fe 100644 --- a/dlls/msi/tests/db.c +++ b/dlls/msi/tests/db.c @@ -9163,14 +9163,14 @@ static void test_view_get_error(void) strcpy(buffer, "x"); err = MsiViewGetErrorA(view, buffer, &sz); ok(err == MSIDBERROR_MOREDATA, "got %d\n", err); - todo_wine ok(!buffer[0], "got "%s"\n", buffer); + ok(!buffer[0], "got "%s"\n", buffer); ok(sz == 1, "got size %u\n", sz);
sz = 1; strcpy(buffer, "x"); err = MsiViewGetErrorA(view, buffer, &sz); todo_wine ok(err == MSIDBERROR_NOERROR, "got %d\n", err); - todo_wine ok(!buffer[0], "got "%s"\n", buffer); + ok(!buffer[0], "got "%s"\n", buffer); todo_wine ok(sz == 0, "got size %u\n", sz);
r = MsiViewModify(view, MSIMODIFY_VALIDATE_NEW, rec);