mirror of
https://github.com/reactos/wine.git
synced 2024-11-28 14:10:32 +00:00
comctl32/mru: In EnumMRUListA, ensure that the string is NULL terminated and the correct size is returned.
This commit is contained in:
parent
3fbe40e2f9
commit
78ce24d632
@ -885,9 +885,11 @@ INT WINAPI EnumMRUListA (HANDLE hList, INT nItemPos, LPVOID lpBuffer,
|
||||
} else {
|
||||
lenA = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)&witem->datastart, -1,
|
||||
NULL, 0, NULL, NULL);
|
||||
datasize = min( witem->size, nBufferSize );
|
||||
datasize = min( lenA, nBufferSize );
|
||||
WideCharToMultiByte(CP_ACP, 0, (LPWSTR)&witem->datastart, -1,
|
||||
lpBuffer, datasize, NULL, NULL);
|
||||
((char *)lpBuffer)[ datasize - 1 ] = '\0';
|
||||
datasize = lenA - 1;
|
||||
}
|
||||
TRACE("(%p, %d, %p, %d): returning len=%d\n",
|
||||
hList, nItemPos, lpBuffer, nBufferSize, datasize);
|
||||
|
@ -385,7 +385,7 @@ static void test_MRUListA(void)
|
||||
/* check entry 0 */
|
||||
buffer[0] = 0;
|
||||
iRet = pEnumMRUList(hMRU, 0, buffer, 255);
|
||||
todo_wine ok(iRet == lstrlen(checks[3]), "EnumMRUList expected %d, got %d\n", lstrlen(checks[3]), iRet);
|
||||
ok(iRet == lstrlen(checks[3]), "EnumMRUList expected %d, got %d\n", lstrlen(checks[3]), iRet);
|
||||
ok(strcmp(buffer, checks[3]) == 0, "EnumMRUList expected %s, got %s\n", checks[3], buffer);
|
||||
|
||||
/* check entry 0 with a too small buffer */
|
||||
@ -394,21 +394,21 @@ static void test_MRUListA(void)
|
||||
buffer[2] = 'A'; /* unchanged */
|
||||
buffer[3] = 0; /* unchanged */
|
||||
iRet = pEnumMRUList(hMRU, 0, buffer, 2);
|
||||
todo_wine ok(iRet == lstrlen(checks[3]), "EnumMRUList expected %d, got %d\n", lstrlen(checks[3]), iRet);
|
||||
todo_wine ok(strcmp(buffer, "T") == 0, "EnumMRUList expected %s, got %s\n", "T", buffer);
|
||||
ok(iRet == lstrlen(checks[3]), "EnumMRUList expected %d, got %d\n", lstrlen(checks[3]), iRet);
|
||||
ok(strcmp(buffer, "T") == 0, "EnumMRUList expected %s, got %s\n", "T", buffer);
|
||||
/* make sure space after buffer has old values */
|
||||
ok(buffer[2] == 'A', "EnumMRUList expected %02x, got %02x\n", 'A', buffer[2]);
|
||||
|
||||
/* check entry 1 */
|
||||
buffer[0] = 0;
|
||||
iRet = pEnumMRUList(hMRU, 1, buffer, 255);
|
||||
todo_wine ok(iRet == lstrlen(checks[1]), "EnumMRUList expected %d, got %d\n", lstrlen(checks[1]), iRet);
|
||||
ok(iRet == lstrlen(checks[1]), "EnumMRUList expected %d, got %d\n", lstrlen(checks[1]), iRet);
|
||||
ok(strcmp(buffer, checks[1]) == 0, "EnumMRUList expected %s, got %s\n", checks[1], buffer);
|
||||
|
||||
/* check entry 2 */
|
||||
buffer[0] = 0;
|
||||
iRet = pEnumMRUList(hMRU, 2, buffer, 255);
|
||||
todo_wine ok(iRet == lstrlen(checks[2]), "EnumMRUList expected %d, got %d\n", lstrlen(checks[2]), iRet);
|
||||
ok(iRet == lstrlen(checks[2]), "EnumMRUList expected %d, got %d\n", lstrlen(checks[2]), iRet);
|
||||
ok(strcmp(buffer, checks[2]) == 0, "EnumMRUList expected %s, got %s\n", checks[2], buffer);
|
||||
|
||||
/* check out of bounds entry 3 */
|
||||
|
Loading…
Reference in New Issue
Block a user