MacOSFontEntry::mIsCFF may be used without initialization

RESOLVED FIXED

Status

()

Core
Graphics
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: jfkthame, Assigned: jfkthame)

Tracking

Trunk
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Assignee)

Description

6 years ago
Created attachment 529081 [details] [diff] [review]
patch, ensure IsCFF() initializes the field, whether TRUE or FALSE

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 1

6 years ago
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-
(Assignee)

Comment 2

6 years ago
Created attachment 529426 [details] [diff] [review]
patch, alternative version

(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 3

6 years ago
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+
(Assignee)

Comment 4

6 years ago
http://hg.mozilla.org/mozilla-central/rev/1b9584c937a7
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.