Make it human friendly code.
DWORD dwType)
{
UNICODE_STRING EntryFileName;
DWORD dwType)
{
UNICODE_STRING EntryFileName;
- POBJECT_NAME_INFORMATION NameInfo1, NameInfo2;
+ POBJECT_NAME_INFORMATION NameInfo1 = NULL, NameInfo2 = NULL;
PLIST_ENTRY ListEntry;
PFONT_ENTRY FontEntry;
ULONG Size, i, Count;
PLIST_ENTRY ListEntry;
PFONT_ENTRY FontEntry;
ULONG Size, i, Count;
BOOL IsEqual;
FONTFAMILYINFO *FamInfo;
const ULONG MaxFamInfo = 64;
BOOL IsEqual;
FONTFAMILYINFO *FamInfo;
const ULONG MaxFamInfo = 64;
+ const ULONG MAX_FAM_INFO_BYTES = sizeof(FONTFAMILYINFO) * MaxFamInfo;
+ const ULONG NAMEINFO_SIZE = sizeof(OBJECT_NAME_INFORMATION) + MAX_PATH * sizeof(WCHAR);
DPRINT("IntGdiGetFontResourceInfo: dwType == %lu\n", dwType);
DPRINT("IntGdiGetFontResourceInfo: dwType == %lu\n", dwType);
- /* Create buffer for full path name */
- Size = sizeof(OBJECT_NAME_INFORMATION) + MAX_PATH * sizeof(WCHAR);
- NameInfo1 = ExAllocatePoolWithTag(PagedPool, Size, TAG_FINF);
- if (!NameInfo1)
- EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return FALSE;
- }
+ /* Create buffer for full path name */
+ NameInfo1 = ExAllocatePoolWithTag(PagedPool, NAMEINFO_SIZE, TAG_FINF);
+ if (!NameInfo1)
+ break;
- /* Get the full path name */
- if (!IntGetFullFileName(NameInfo1, Size, FileName))
- {
- ExFreePoolWithTag(NameInfo1, TAG_FINF);
- return FALSE;
- }
+ /* Get the full path name */
+ if (!IntGetFullFileName(NameInfo1, NAMEINFO_SIZE, FileName))
+ break;
- /* Create a buffer for the entries' names */
- NameInfo2 = ExAllocatePoolWithTag(PagedPool, Size, TAG_FINF);
- if (!NameInfo2)
- {
- ExFreePoolWithTag(NameInfo1, TAG_FINF);
- EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return FALSE;
- }
+ /* Create a buffer for the entries' names */
+ NameInfo2 = ExAllocatePoolWithTag(PagedPool, NAMEINFO_SIZE, TAG_FINF);
+ if (!NameInfo2)
+ break;
- FamInfo = ExAllocatePoolWithTag(PagedPool,
- sizeof(FONTFAMILYINFO) * MaxFamInfo,
- TAG_FINF);
- if (!FamInfo)
+ FamInfo = ExAllocatePoolWithTag(PagedPool, MAX_FAM_INFO_BYTES, TAG_FINF);
+ } while (0);
+
+ if (!NameInfo1 || !NameInfo2 || !FamInfo)
- ExFreePoolWithTag(NameInfo2, TAG_FINF);
- ExFreePoolWithTag(NameInfo1, TAG_FINF);
+ if (NameInfo2)
+ ExFreePoolWithTag(NameInfo2, TAG_FINF);
+
+ if (NameInfo1)
+ ExFreePoolWithTag(NameInfo1, TAG_FINF);
+
EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
- /* Try to find the pathname in the global font list */
+
+ /* Try to find the pathname in the global font list */
IntLockGlobalFonts();
for (ListEntry = g_FontListHead.Flink; ListEntry != &g_FontListHead;
ListEntry = ListEntry->Flink)
IntLockGlobalFonts();
for (ListEntry = g_FontListHead.Flink; ListEntry != &g_FontListHead;
ListEntry = ListEntry->Flink)
continue;
RtlInitUnicodeString(&EntryFileName , FontEntry->Font->Filename);
continue;
RtlInitUnicodeString(&EntryFileName , FontEntry->Font->Filename);
- if (!IntGetFullFileName(NameInfo2, Size, &EntryFileName))
+ if (!IntGetFullFileName(NameInfo2, NAMEINFO_SIZE, &EntryFileName))
continue;
if (!RtlEqualUnicodeString(&NameInfo1->Name, &NameInfo2->Name, FALSE))
continue;
if (!RtlEqualUnicodeString(&NameInfo1->Name, &NameInfo2->Name, FALSE))