From 61b6e9119ff21538e56f345b60f8f0293ef6d39d Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Fri, 25 Mar 2011 23:09:06 +0000 Subject: [PATCH] [WIN32K] wcsncpy -> RtlStringCbCopyW (part 4/x) Avoid unneeded allocation svn path=/trunk/; revision=51144 --- .../win32/win32k/objects/freetype.c | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/reactos/subsystems/win32/win32k/objects/freetype.c b/reactos/subsystems/win32/win32k/objects/freetype.c index 4e941ee2047..c7086fd39d4 100644 --- a/reactos/subsystems/win32/win32k/objects/freetype.c +++ b/reactos/subsystems/win32/win32k/objects/freetype.c @@ -1078,12 +1078,16 @@ FontFamilyFillInfo(PFONTFAMILYINFO Info, PCWSTR FaceName, PFONTGDI FontGDI) ExFreePoolWithTag(Otm, GDITAG_TEXT); - wcsncpy(Info->EnumLogFontEx.elfLogFont.lfFaceName, FaceName, LF_FACESIZE); - wcsncpy(Info->EnumLogFontEx.elfFullName, FaceName, LF_FULLFACESIZE); + RtlStringCbCopyW(Info->EnumLogFontEx.elfLogFont.lfFaceName, + sizeof(Info->EnumLogFontEx.elfLogFont.lfFaceName), + FaceName); + RtlStringCbCopyW(Info->EnumLogFontEx.elfFullName, + sizeof(Info->EnumLogFontEx.elfFullName), + FaceName); RtlInitAnsiString(&StyleA, FontGDI->face->style_name); - RtlAnsiStringToUnicodeString(&StyleW, &StyleA, TRUE); - wcsncpy(Info->EnumLogFontEx.elfStyle, StyleW.Buffer, LF_FACESIZE); - RtlFreeUnicodeString(&StyleW); + StyleW.Buffer = Info->EnumLogFontEx.elfStyle; + StyleW.MaximumLength = sizeof(Info->EnumLogFontEx.elfStyle); + RtlAnsiStringToUnicodeString(&StyleW, &StyleA, FALSE); Info->EnumLogFontEx.elfLogFont.lfCharSet = DEFAULT_CHARSET; Info->EnumLogFontEx.elfScript[0] = L'\0'; @@ -1267,8 +1271,10 @@ FontFamilyInfoQueryRegistryCallback(IN PWSTR ValueName, IN ULONG ValueType, if (InfoContext->Count < InfoContext->Size) { InfoContext->Info[InfoContext->Count] = InfoContext->Info[Existing]; - wcsncpy(InfoContext->Info[InfoContext->Count].EnumLogFontEx.elfLogFont.lfFaceName, - RegistryName.Buffer, LF_FACESIZE); + RtlStringCbCopyNW(InfoContext->Info[InfoContext->Count].EnumLogFontEx.elfLogFont.lfFaceName, + sizeof(InfoContext->Info[InfoContext->Count].EnumLogFontEx.elfLogFont.lfFaceName), + RegistryName.Buffer, + RegistryName.Length); } InfoContext->Count++; return STATUS_SUCCESS; @@ -2643,7 +2649,7 @@ FindBestFontFromList(FONTOBJ **FontObj, UINT *MatchScore, LOGFONTW *LogFont, PFONT_ENTRY CurrentEntry; FONTGDI *FontGDI; UINT Score; - +ASSERT(FontObj && MatchScore && LogFont && FaceName && Head); Entry = Head->Flink; while (Entry != Head) {