[GDI32] Improve IntFontFamilyListUnique function (#1491)
authorKatayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
Tue, 9 Apr 2019 08:39:42 +0000 (17:39 +0900)
committerGitHub <noreply@github.com>
Tue, 9 Apr 2019 08:39:42 +0000 (17:39 +0900)
Make gdi32!IntFontFamilyListUnique function std::unique compatible. Previous code didn't set the first entry correctly. CORE-15785

win32ss/gdi/gdi32/objects/font.c

index a42b02c..2f187b0 100644 (file)
@@ -264,18 +264,19 @@ IntFontFamilyListUnique(FONTFAMILYINFO *InfoList, INT nCount,
     if ((dwFlags & IEFF_EXTENDED) && plf->lfCharSet == DEFAULT_CHARSET)
         dwCompareFlags |= IFFCX_CHARSET;
 
+    first = InfoList;
+    last = &InfoList[nCount];
+
     // std::unique(first, last, IntFontFamilyCompareEx);
-    if (nCount == 0)
+    if (first == last)
         return 0;
 
-    result = first = InfoList;
-    last = &InfoList[nCount];
+    result = first;
     while (++first != last)
     {
-        if (IntFontFamilyCompareEx(result, first, dwCompareFlags) != 0 &&
-            ++result != first)
+        if (IntFontFamilyCompareEx(result, first, dwCompareFlags) != 0)
         {
-            *result = *first;
+            *(++result) = *first;
         }
     }
     nCount = (int)(++result - InfoList);