+Finish:
+ if (iFace == FaceCount)
+ {
+ /*
+ * We succeeded, append the created font entries into the correct font table.
+ */
+ PLIST_ENTRY ListToAppend;
+
+ /* No typefaces were present */
+ if (FaceCount == 0)
+ {
+ ASSERT(IsListEmpty(&LoadedFontList));
+ return 0;
+ }
+
+ ASSERT(!IsListEmpty(&LoadedFontList));
+
+ /*
+ * Remove the temporary font list' head and reinitialize it.
+ * This effectively empties the list and at the same time transforms
+ * 'ListToAppend' into a headless list, ready to be appended to the
+ * suitable font table.
+ */
+ ListToAppend = LoadedFontList.Flink;
+ RemoveEntryList(&LoadedFontList);
+ InitializeListHead(&LoadedFontList);
+
+ if (Characteristics & FR_PRIVATE)
+ {
+ /* Private font */
+ PPROCESSINFO Win32Process = PsGetCurrentProcessWin32Process();
+ IntLockProcessPrivateFonts(Win32Process);
+ AppendTailList(&Win32Process->PrivateFontListHead, ListToAppend);
+ IntUnLockProcessPrivateFonts(Win32Process);
+ }
+ else
+ {
+ /* Global font */
+ IntLockGlobalFonts();
+ AppendTailList(&g_FontListHead, ListToAppend);
+ IntUnLockGlobalFonts();
+ }
+
+ return FaceCount; /* Number of loaded faces */
+ }
+ else
+ {
+ /* We failed, cleanup the resources */
+ PLIST_ENTRY ListEntry;
+
+ if (pLoadFont->PrivateEntry)
+ {
+ while (!IsListEmpty(&pLoadFont->PrivateEntry->ListEntry))
+ {
+ ListEntry = RemoveHeadList(&pLoadFont->PrivateEntry->ListEntry);
+ PrivateEntry = CONTAINING_RECORD(ListEntry, FONT_ENTRY_MEM, ListEntry);
+ ExFreePoolWithTag(PrivateEntry, TAG_FONT);
+ }
+ ExFreePoolWithTag(pLoadFont->PrivateEntry, TAG_FONT);
+ pLoadFont->PrivateEntry = NULL;
+ }
+
+ while (!IsListEmpty(&LoadedFontList))
+ {
+ ListEntry = RemoveHeadList(&LoadedFontList);
+ Entry = CONTAINING_RECORD(ListEntry, FONT_ENTRY, ListEntry);
+ CleanupFontEntry(Entry);
+ }
+
+ return 0; /* No faces have been added */
+ }