Vincent Povirk : gdiplus: Return copies of fonts from GdipGetFontCollectionFamilyList.

Alexandre Julliard julliard at winehq.org
Mon Jul 19 11:05:38 CDT 2010


Module: wine
Branch: master
Commit: 5694825ae3c3a581976716a62e1b2d1fb54e5674
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5694825ae3c3a581976716a62e1b2d1fb54e5674

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Sat Jun 19 17:50:00 2010 -0500

gdiplus: Return copies of fonts from GdipGetFontCollectionFamilyList.

---

 dlls/gdiplus/font.c |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c
index f198863..2670e81 100644
--- a/dlls/gdiplus/font.c
+++ b/dlls/gdiplus/font.c
@@ -963,18 +963,33 @@ GpStatus WINGDIPAPI GdipGetFontCollectionFamilyList(
         GpFontFamily* gpfamilies[], INT* numFound)
 {
     INT i;
+    GpStatus stat=Ok;
 
     TRACE("%p, %d, %p, %p\n", fontCollection, numSought, gpfamilies, numFound);
 
     if (!(fontCollection && gpfamilies && numFound))
         return InvalidParameter;
 
-    for (i = 0; i < numSought && i < fontCollection->count; i++)
+    memset(gpfamilies, 0, sizeof(*gpfamilies) * numSought);
+
+    for (i = 0; i < numSought && i < fontCollection->count && stat == Ok; i++)
     {
-        gpfamilies[i] = fontCollection->FontFamilies[i];
+        stat = GdipCloneFontFamily(fontCollection->FontFamilies[i], &gpfamilies[i]);
     }
-    *numFound = i;
-    return Ok;
+
+    if (stat == Ok)
+        *numFound = i;
+    else
+    {
+        int numToFree=i;
+        for (i=0; i<numToFree; i++)
+        {
+            GdipDeleteFontFamily(gpfamilies[i]);
+            gpfamilies[i] = NULL;
+        }
+    }
+
+    return stat;
 }
 
 void free_installed_fonts(void)




More information about the wine-cvs mailing list