[Webkit-unassigned] [Bug 91506] New: Typo in FontCacheWin.cpp causes return value from getCachedFontData() in getLastResortFallbackFont() to be ignored

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Jul 17 09:05:02 PDT 2012


https://bugs.webkit.org/show_bug.cgi?id=91506

           Summary: Typo in FontCacheWin.cpp causes return value from
                    getCachedFontData() in getLastResortFallbackFont() to
                    be ignored
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: PC
        OS/Version: Windows 7
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: Platform
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: mark.salisbury at hp.com


Created an attachment (id=152770)
 --> (https://bugs.webkit.org/attachment.cgi?id=152770&action=review)
Page which I used to reproduce bug

In FontCacheWin.cpp, getLastResortFallbackFont(), currently line 340, I believe there is a typo that causes the return from getCachedFontData() to be ignored.  I'm a little surprised the compiler even allows this.  The problem is that the closing parenthesis is in the wrong place:

338    SimpleFontData* simpleFont;
339    for (size_t i = 0; i < WTF_ARRAY_LENGTH(fallbackFonts); ++i) {
340        if (simpleFont = getCachedFontData(fontDescription, fallbackFonts[i]), false, shouldRetain) {
341            fallbackFontName = fallbackFonts[i];
342            return simpleFont;
343        }
344    }

It should look like this:

340        if (simpleFont = getCachedFontData(fontDescription, fallbackFonts[i], false, shouldRetain)) {

There is more 'fallback' code after this section; it checks for "a DEFAULT_GUI_FONT is no known Unicode font is available".  Because of this a fallback font will be found.  It looks like this was introduced last year (http://trac.webkit.org/changeset/93140) when the shouldRetain parameter was added to getCachedFontData().

I discovered this by porting this code to Windows CE, which does not support GetStockObject(DEFAULT_GUI_FONT).  After binding out this section of code near the bottom of the function, I hit the ASSERT_NOT_REACHED.  Moving the parenthesis fixes the crash.

Steps to reproduce:
1) Load a page which does not specify a font (I attached the page I found the bug with).
2) Specify in preferences that the webkit standard font is a font which your system does not have (so that the last resort fallback code will be invoked).

Set a breakpoint in getLastResortFallbackFont().  You'll notice that even though it invokes getCachedFontData() on line 340, and the function returns a valid SimpleFontData *, the value is ignored; the code loops through all the fonts then it hits the "last last" resort fallback font code.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list