Index: freetype.c =================================================================== --- win32ss/gdi/ntgdi/freetype.c (revision 74578) +++ win32ss/gdi/ntgdi/freetype.c (working copy) @@ -1761,21 +1761,25 @@ char *Cp; FT_Face Face = FontGDI->SharedFace->Face; UNICODE_STRING FamilyNameW, FaceNameW, StyleNameW, FullNameW; + WCHAR FamilyNameWBuffer[128]; + WCHAR FaceNameWBuffer[128]; + WCHAR StyleNameWBuffer[128]; + WCHAR FullNameWBuffer[128]; /* family name */ - RtlInitUnicodeString(&FamilyNameW, NULL); + RtlInitEmptyUnicodeString(&FamilyNameW, FamilyNameWBuffer, sizeof(FamilyNameWBuffer)); IntGetFontLocalizedName(&FamilyNameW, Face, TT_NAME_ID_FONT_FAMILY, gusLanguageID); /* face name */ - RtlInitUnicodeString(&FaceNameW, NULL); + RtlInitEmptyUnicodeString(&FaceNameW, FaceNameWBuffer, sizeof(FaceNameWBuffer)); IntGetFontLocalizedName(&FaceNameW, Face, TT_NAME_ID_FULL_NAME, gusLanguageID); /* style name */ - RtlInitUnicodeString(&StyleNameW, NULL); + RtlInitEmptyUnicodeString(&StyleNameW, StyleNameWBuffer, sizeof(StyleNameWBuffer)); IntGetFontLocalizedName(&StyleNameW, Face, TT_NAME_ID_FONT_SUBFAMILY, gusLanguageID); /* unique name (full name) */ - RtlInitUnicodeString(&FullNameW, NULL); + RtlInitEmptyUnicodeString(&FullNameW, FullNameWBuffer, sizeof(FullNameWBuffer)); IntGetFontLocalizedName(&FullNameW, Face, TT_NAME_ID_UNIQUE_ID, gusLanguageID); Needed = sizeof(OUTLINETEXTMETRICW); @@ -1786,10 +1790,6 @@ if (Size < Needed) { - RtlFreeUnicodeString(&FamilyNameW); - RtlFreeUnicodeString(&FaceNameW); - RtlFreeUnicodeString(&StyleNameW); - RtlFreeUnicodeString(&FullNameW); return Needed; } @@ -1802,10 +1802,6 @@ { IntUnLockFreeType; DPRINT1("Can't find OS/2 table - not TT font?\n"); - RtlFreeUnicodeString(&FamilyNameW); - RtlFreeUnicodeString(&FaceNameW); - RtlFreeUnicodeString(&StyleNameW); - RtlFreeUnicodeString(&FullNameW); return 0; } @@ -1814,10 +1810,6 @@ { IntUnLockFreeType; DPRINT1("Can't find HHEA table - not TT font?\n"); - RtlFreeUnicodeString(&FamilyNameW); - RtlFreeUnicodeString(&FaceNameW); - RtlFreeUnicodeString(&StyleNameW); - RtlFreeUnicodeString(&FullNameW); return 0; } @@ -1897,11 +1889,6 @@ ASSERT(Cp - (char*)Otm == Needed); - RtlFreeUnicodeString(&FamilyNameW); - RtlFreeUnicodeString(&FaceNameW); - RtlFreeUnicodeString(&StyleNameW); - RtlFreeUnicodeString(&FullNameW); - return Needed; } @@ -2039,13 +2026,12 @@ { FT_SfntName Name; INT i, Count; + UNICODE_STRING BufString; WCHAR Buf[LF_FULLFACESIZE]; FT_Error Error; NTSTATUS Status = STATUS_NOT_FOUND; ANSI_STRING AnsiName; - RtlFreeUnicodeString(pNameW); - Count = FT_Get_Sfnt_Name_Count(Face); for (i = 0; i < Count; ++i) { @@ -2078,11 +2064,13 @@ /* NOTE: Name.string is not null-terminated */ RtlCopyMemory(Buf, Name.string, Name.string_len); Buf[Name.string_len / sizeof(WCHAR)] = UNICODE_NULL; + RtlInitEmptyUnicodeString(&BufString, Buf, sizeof(Buf)); + BufString.Length = Name.string_len; /* Convert UTF-16 big endian to little endian */ SwapEndian(Buf, Name.string_len); - RtlCreateUnicodeString(pNameW, Buf); + RtlCopyUnicodeString(pNameW, &BufString); Status = STATUS_SUCCESS; break; } @@ -2097,12 +2085,12 @@ else if (NameID == TT_NAME_ID_FONT_SUBFAMILY) { RtlInitAnsiString(&AnsiName, Face->style_name); - Status = RtlAnsiStringToUnicodeString(pNameW, &AnsiName, TRUE); + Status = RtlAnsiStringToUnicodeString(pNameW, &AnsiName, FALSE); } else { RtlInitAnsiString(&AnsiName, Face->family_name); - Status = RtlAnsiStringToUnicodeString(pNameW, &AnsiName, TRUE); + Status = RtlAnsiStringToUnicodeString(pNameW, &AnsiName, FALSE); } } @@ -2127,8 +2115,9 @@ NTSTATUS status; FT_Face Face = FontGDI->SharedFace->Face; UNICODE_STRING NameW; + WCHAR NameWBuffer[128]; - RtlInitUnicodeString(&NameW, NULL); + RtlInitEmptyUnicodeString(&NameW, NameWBuffer, sizeof(NameWBuffer)); RtlZeroMemory(Info, sizeof(FONTFAMILYINFO)); Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL); Otm = ExAllocatePoolWithTag(PagedPool, Size, GDITAG_TEXT); @@ -2204,7 +2193,6 @@ /* store it */ RtlStringCbCopyW(Lf->lfFaceName, sizeof(Lf->lfFaceName), NameW.Buffer); - RtlFreeUnicodeString(&NameW); } } @@ -2225,7 +2213,6 @@ RtlStringCbCopyW(Info->EnumLogFontEx.elfFullName, sizeof(Info->EnumLogFontEx.elfFullName), NameW.Buffer); - RtlFreeUnicodeString(&NameW); } } @@ -4337,6 +4324,7 @@ FONTGDI *FontGDI; ANSI_STRING ActualNameA; UNICODE_STRING ActualNameW, FullFaceNameW; + WCHAR ActualNameWBuffer[128]; OUTLINETEXTMETRICW *Otm = NULL; UINT OtmSize, OldOtmSize = 0; TEXTMETRICW *TM; @@ -4349,6 +4337,7 @@ ASSERT(pRequestedNameW); ASSERT(Head); + RtlInitEmptyUnicodeString(&ActualNameW, ActualNameWBuffer, sizeof(ActualNameWBuffer)); /* get the FontObj of lowest penalty */ Entry = Head->Flink; while (Entry != Head) @@ -4360,7 +4349,7 @@ /* create actual name */ RtlInitAnsiString(&ActualNameA, Face->family_name); - Status = RtlAnsiStringToUnicodeString(&ActualNameW, &ActualNameA, TRUE); + Status = RtlAnsiStringToUnicodeString(&ActualNameW, &ActualNameA, FALSE); if (!NT_SUCCESS(Status)) { /* next entry */ @@ -4389,7 +4378,6 @@ Status = RtlCreateUnicodeString(&FullFaceNameW, (LPWSTR)pb); if (!NT_SUCCESS(Status)) { - RtlFreeUnicodeString(&ActualNameW); RtlFreeUnicodeString(&FullFaceNameW); /* next entry */ Entry = Entry->Flink; @@ -4402,7 +4390,6 @@ if (*MatchPenalty == 0xFFFFFFFF || Penalty < *MatchPenalty) { DPRINT("%ls Penalty: %lu\n", FullFaceNameW.Buffer, Penalty); - RtlFreeUnicodeString(pActualNameW); RtlCreateUnicodeString(pActualNameW, ActualNameW.Buffer); *FontObj = GDIToObj(FontGDI, FONT); @@ -4412,9 +4399,6 @@ RtlFreeUnicodeString(&FullFaceNameW); } - /* free strings */ - RtlFreeUnicodeString(&ActualNameW); - /* next entry */ Entry = Entry->Flink; }