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
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
if (msi_strncpyW(column, -1, buffer, buflen) == ERROR_MORE_DATA)
r = MSIDBERROR_MOREDATA;
}
*buflen = len;
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
if (msi_strncpyWtoA(column, -1, buffer, buflen, FALSE) == ERROR_MORE_DATA)
r = MSIDBERROR_MOREDATA;
}
*buflen = len - 1;
msiobj_release( &query->hdr );
return r;
}
......
......@@ -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);
......
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