mirror of
https://github.com/reactos/reactos.git
synced 2024-08-29 14:48:37 +00:00
- Don't copy data to null buffer, just return the string length in this case
- Fix some buffer calculation problems, handle buffer termination if it's shorter than the font string - Fixes >= 10 gdi32 font winetests (NtGdiGetTextFaceW/NtGdiGetTextFaceA related) svn path=/trunk/; revision=40469
This commit is contained in:
parent
9e3589a7b1
commit
72585aa30d
|
@ -326,6 +326,7 @@ NtGdiGetTextFaceW(
|
|||
HFONT hFont;
|
||||
PTEXTOBJ TextObj;
|
||||
NTSTATUS Status;
|
||||
INT fLen, ret;
|
||||
|
||||
/* FIXME: Handle bAliasName */
|
||||
|
||||
|
@ -341,16 +342,32 @@ NtGdiGetTextFaceW(
|
|||
|
||||
TextObj = RealizeFontInit(hFont);
|
||||
ASSERT(TextObj != NULL);
|
||||
Count = min(Count, wcslen(TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfFaceName));
|
||||
Status = MmCopyToCaller(FaceName, TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfFaceName, Count * sizeof(WCHAR));
|
||||
TEXTOBJ_UnlockText(TextObj);
|
||||
if (!NT_SUCCESS(Status))
|
||||
fLen = wcslen(TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfFaceName) + 1;
|
||||
|
||||
if (FaceName != NULL)
|
||||
{
|
||||
SetLastNtError(Status);
|
||||
return 0;
|
||||
Count = min(Count, fLen);
|
||||
Status = MmCopyToCaller(FaceName, TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfFaceName, Count * sizeof(WCHAR));
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
TEXTOBJ_UnlockText(TextObj);
|
||||
SetLastNtError(Status);
|
||||
return 0;
|
||||
}
|
||||
/* Terminate if we copied only part of the font name */
|
||||
if (Count > 0 && Count < fLen)
|
||||
{
|
||||
FaceName[Count - 1] = '\0';
|
||||
}
|
||||
ret = Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = fLen;
|
||||
}
|
||||
|
||||
return Count;
|
||||
TEXTOBJ_UnlockText(TextObj);
|
||||
return ret;
|
||||
}
|
||||
|
||||
W32KAPI
|
||||
|
|
Loading…
Reference in a new issue