Commit 6a3dbf11 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

msi: Perform partial copies in MsiViewGetError().

parent fac04043
...@@ -772,7 +772,6 @@ MSIDBERROR WINAPI MsiViewGetErrorW( MSIHANDLE handle, LPWSTR buffer, LPDWORD buf ...@@ -772,7 +772,6 @@ MSIDBERROR WINAPI MsiViewGetErrorW( MSIHANDLE handle, LPWSTR buffer, LPDWORD buf
MSIQUERY *query; MSIQUERY *query;
const WCHAR *column; const WCHAR *column;
MSIDBERROR r; MSIDBERROR r;
DWORD len;
TRACE("%u %p %p\n", handle, buffer, buflen); TRACE("%u %p %p\n", handle, buffer, buflen);
...@@ -786,15 +785,9 @@ MSIDBERROR WINAPI MsiViewGetErrorW( MSIHANDLE handle, LPWSTR buffer, LPDWORD buf ...@@ -786,15 +785,9 @@ MSIDBERROR WINAPI MsiViewGetErrorW( MSIHANDLE handle, LPWSTR buffer, LPDWORD buf
if ((r = query->view->error)) column = query->view->error_column; if ((r = query->view->error)) column = query->view->error_column;
else column = szEmpty; else column = szEmpty;
len = strlenW( column ); if (msi_strncpyW(column, -1, buffer, buflen) == ERROR_MORE_DATA)
if (buffer) r = MSIDBERROR_MOREDATA;
{
if (*buflen > len)
strcpyW( buffer, column );
else
r = MSIDBERROR_MOREDATA;
}
*buflen = len;
msiobj_release( &query->hdr ); msiobj_release( &query->hdr );
return r; return r;
} }
...@@ -804,7 +797,6 @@ MSIDBERROR WINAPI MsiViewGetErrorA( MSIHANDLE handle, LPSTR buffer, LPDWORD bufl ...@@ -804,7 +797,6 @@ MSIDBERROR WINAPI MsiViewGetErrorA( MSIHANDLE handle, LPSTR buffer, LPDWORD bufl
MSIQUERY *query; MSIQUERY *query;
const WCHAR *column; const WCHAR *column;
MSIDBERROR r; MSIDBERROR r;
DWORD len;
TRACE("%u %p %p\n", handle, buffer, buflen); TRACE("%u %p %p\n", handle, buffer, buflen);
...@@ -818,15 +810,9 @@ MSIDBERROR WINAPI MsiViewGetErrorA( MSIHANDLE handle, LPSTR buffer, LPDWORD bufl ...@@ -818,15 +810,9 @@ MSIDBERROR WINAPI MsiViewGetErrorA( MSIHANDLE handle, LPSTR buffer, LPDWORD bufl
if ((r = query->view->error)) column = query->view->error_column; if ((r = query->view->error)) column = query->view->error_column;
else column = szEmpty; else column = szEmpty;
len = WideCharToMultiByte( CP_ACP, 0, column, -1, NULL, 0, NULL, NULL ); if (msi_strncpyWtoA(column, -1, buffer, buflen, FALSE) == ERROR_MORE_DATA)
if (buffer) r = MSIDBERROR_MOREDATA;
{
if (*buflen >= len)
WideCharToMultiByte( CP_ACP, 0, column, -1, buffer, *buflen, NULL, NULL );
else
r = MSIDBERROR_MOREDATA;
}
*buflen = len - 1;
msiobj_release( &query->hdr ); msiobj_release( &query->hdr );
return r; return r;
} }
......
...@@ -9163,14 +9163,14 @@ static void test_view_get_error(void) ...@@ -9163,14 +9163,14 @@ static void test_view_get_error(void)
strcpy(buffer, "x"); strcpy(buffer, "x");
err = MsiViewGetErrorA(view, buffer, &sz); err = MsiViewGetErrorA(view, buffer, &sz);
ok(err == MSIDBERROR_MOREDATA, "got %d\n", err); 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); ok(sz == 1, "got size %u\n", sz);
sz = 1; sz = 1;
strcpy(buffer, "x"); strcpy(buffer, "x");
err = MsiViewGetErrorA(view, buffer, &sz); err = MsiViewGetErrorA(view, buffer, &sz);
todo_wine ok(err == MSIDBERROR_NOERROR, "got %d\n", err); 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); todo_wine ok(sz == 0, "got size %u\n", sz);
r = MsiViewModify(view, MSIMODIFY_VALIDATE_NEW, rec); r = MsiViewModify(view, MSIMODIFY_VALIDATE_NEW, rec);
......
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