Nikolay Sivov : oleaut32: FONTDESC size field value is not important for OleCreateFontIndirect.

Alexandre Julliard julliard at winehq.org
Mon Aug 22 13:29:12 CDT 2011


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Sun Aug 21 17:53:12 2011 +0400

oleaut32: FONTDESC size field value is not important for OleCreateFontIndirect.

---

 dlls/oleaut32/olefont.c       |    5 -----
 dlls/oleaut32/tests/olefont.c |   37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/dlls/oleaut32/olefont.c b/dlls/oleaut32/olefont.c
index fa60da6..222e20d 100644
--- a/dlls/oleaut32/olefont.c
+++ b/dlls/oleaut32/olefont.c
@@ -2245,11 +2245,6 @@ static OLEFontImpl* OLEFontImpl_Construct(const FONTDESC *fontDesc)
 
   newObject->ref = 1;
 
-  /*
-   * Copy the description of the font in the object.
-   */
-  assert(fontDesc->cbSizeofstruct >= sizeof(FONTDESC));
-
   newObject->description.cbSizeofstruct = sizeof(FONTDESC);
   newObject->description.lpstrName = HeapAlloc(GetProcessHeap(),
 					       0,
diff --git a/dlls/oleaut32/tests/olefont.c b/dlls/oleaut32/tests/olefont.c
index 65589b3..6fc1520 100644
--- a/dlls/oleaut32/tests/olefont.c
+++ b/dlls/oleaut32/tests/olefont.c
@@ -1104,6 +1104,42 @@ static void test_realization(void)
     IFont_Release(font);
 }
 
+static void test_OleCreateFontIndirect(void)
+{
+    FONTDESC fontdesc;
+    IFont *font;
+    HRESULT hr;
+
+    fontdesc.cbSizeofstruct = sizeof(fontdesc);
+    fontdesc.lpstrName = arial_font;
+    fontdesc.cySize.int64 = 12 * 10000; /* 12 pt */
+    fontdesc.sWeight = FW_NORMAL;
+    fontdesc.sCharset = ANSI_CHARSET;
+    fontdesc.fItalic = FALSE;
+    fontdesc.fUnderline = FALSE;
+    fontdesc.fStrikethrough = FALSE;
+
+    hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void**)&font);
+    EXPECT_HR(hr, S_OK);
+    IFont_Release(font);
+
+    /* play with cbSizeofstruct value */
+    fontdesc.cbSizeofstruct = sizeof(fontdesc)-1;
+    hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void**)&font);
+    EXPECT_HR(hr, S_OK);
+    IFont_Release(font);
+
+    fontdesc.cbSizeofstruct = sizeof(fontdesc)+1;
+    hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void**)&font);
+    EXPECT_HR(hr, S_OK);
+    IFont_Release(font);
+
+    fontdesc.cbSizeofstruct = 0;
+    hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void**)&font);
+    EXPECT_HR(hr, S_OK);
+    IFont_Release(font);
+}
+
 START_TEST(olefont)
 {
     hOleaut32 = GetModuleHandleA("oleaut32.dll");
@@ -1126,4 +1162,5 @@ START_TEST(olefont)
     test_returns();
     test_hfont_lifetime();
     test_realization();
+    test_OleCreateFontIndirect();
 }




More information about the wine-cvs mailing list