mirror of
https://github.com/reactos/reactos.git
synced 2025-05-01 03:29:37 +00:00
[GDI32] Fix TextOutA multibyte text length overgoing. CORE-14070
This commit is contained in:
parent
132c7d926b
commit
10910ca9e1
1 changed files with 26 additions and 4 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS GDI32
|
||||||
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
||||||
|
* PURPOSE: Text drawing API.
|
||||||
|
* COPYRIGHT: Copyright 2014 Timo Kreuzer
|
||||||
|
* Copyright 2017 Katayama Hirofumi MZ
|
||||||
|
*/
|
||||||
|
|
||||||
#include <precomp.h>
|
#include <precomp.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
|
@ -18,18 +26,32 @@ TextOutA(
|
||||||
ANSI_STRING StringA;
|
ANSI_STRING StringA;
|
||||||
UNICODE_STRING StringU;
|
UNICODE_STRING StringU;
|
||||||
BOOL bResult;
|
BOOL bResult;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
if (lpString != NULL)
|
if (lpString != NULL && cchString > 0)
|
||||||
{
|
{
|
||||||
RtlInitAnsiString(&StringA, (LPSTR)lpString);
|
if (cchString > MAXUSHORT)
|
||||||
RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
|
cchString = MAXUSHORT;
|
||||||
|
|
||||||
|
StringA.Length = (USHORT)cchString;
|
||||||
|
StringA.MaximumLength = (USHORT)cchString;
|
||||||
|
StringA.Buffer = (PCHAR)lpString;
|
||||||
|
|
||||||
|
Status = RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
StringU.Buffer = NULL;
|
||||||
|
StringU.Length = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringU.Buffer = NULL;
|
StringU.Buffer = NULL;
|
||||||
|
StringU.Length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bResult = TextOutW(hdc, nXStart, nYStart, StringU.Buffer, cchString);
|
bResult = TextOutW(hdc, nXStart, nYStart,
|
||||||
|
StringU.Buffer, StringU.Length / sizeof(WCHAR));
|
||||||
|
|
||||||
RtlFreeUnicodeString(&StringU);
|
RtlFreeUnicodeString(&StringU);
|
||||||
return bResult;
|
return bResult;
|
||||||
|
|
Loading…
Reference in a new issue