Closed Bug 653705 Opened 13 years ago Closed 13 years ago

MacOSFontEntry::mIsCFF may be used without initialization

Categories

(Core :: Graphics, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jfkthame, Assigned: jfkthame)

Details

Attachments

(2 files)

When we create a MacOSFontEntry for a downloadable font, the mIsCFF field is not initialized. The IsCFF() method correctly sets it to TRUE for CFF fonts, but fails to set it to FALSE otherwise (on the assumption that the field was initialized to FALSE in the first place).

The attached patch explicitly sets it to FALSE in IsCFF unless it's supposed to be TRUE, so that initialization in the constructor is no longer necessary.
Attachment #529081 - Flags: review?(jdaggett)
Comment on attachment 529081 [details] [diff] [review]
patch, ensure IsCFF() initializes the field, whether TRUE or FALSE

> MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName, ATSFontRef aFontRef,
>                                PRUint16 aWeight, PRUint16 aStretch, PRUint32 aItalicStyle,
>                                gfxUserFontData *aUserFontData)
>     : gfxFontEntry(aPostscriptName),
>       mATSFontRef(aFontRef),
>       mATSFontRefInitialized(PR_TRUE),
>       mRequiresAAT(PR_FALSE),
>       mIsCFFInitialized(PR_FALSE)

There are two versions of the constructor, one which initializes
mIsCFF, one which doesn't.  I think both should explicitly initialize
the value, rather than the fix you've written.
Attachment #529081 - Flags: review?(jdaggett) → review-
(In reply to comment #1)
> There are two versions of the constructor, one which initializes
> mIsCFF, one which doesn't.

I know - the patch _removed_ the initialization from the constructor that had it, since it's not needed if IsCFF() explicitly sets it to whichever value is appropriate. That way the field is only ever set in one place.

>  I think both should explicitly initialize
> the value, rather than the fix you've written.

Fine, if you prefer.
Attachment #529426 - Flags: review?(jdaggett)
Comment on attachment 529426 [details] [diff] [review]
patch, alternative version

Yeah, always better to have explicit initialization than rely on the "all codepaths initialize it", that's really easy to break in the future.
Attachment #529426 - Flags: review?(jdaggett) → review+
http://hg.mozilla.org/mozilla-central/rev/1b9584c937a7
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: