[Webkit-unassigned] [Bug 246406] New: [WTF] MediaTime: assert not double in timeValue() and timeScale()

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Oct 12 09:19:06 PDT 2022


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

            Bug ID: 246406
           Summary: [WTF] MediaTime: assert not double in timeValue() and
                    timeScale()
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Web Template Framework
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: aboya at igalia.com

A MediaTime can either represent a time as a fraction or as a floating
point number.

Both representations are stored in a union, with a tag in m_timeFlags to
know which one must be used.

timeValue() and timeScale() are the methods used to get the numerator
and denominator of the time when a MediaTime is fractional. However, as
the code stood before this patch, there is no check (even in Debug mode)
to assert this is the case. An accidental use of timeValue() in this
situation would return an int64_t with the bit contents of an IEEE 754
double, which could cause a hard to debug bug. Similarly, timeScale() is
undefined in this case.

This code adds an assert to both methods to guard against accidental
usages on MediaTime instances containing floating point values.

Additionally: these functions used to return references. Doing so
exposes implementation details of MediaTime and would enable dangerous
and confusing uses (e.g. calling timeValue() first, saving it in a
reference variable, updating the MediaTime and checking the variable
afterwards). All existing uses are as an immediate, so they can be
safely refactored to return by value, which is safer.

* Source/WTF/wtf/MediaTime.h:

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20221012/7ff2a800/attachment.htm>


More information about the webkit-unassigned mailing list